library (ggplot2)
library (tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library (dplyr)
library(patchwork)
###load photo data for each region and year

mojave_2022 <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/camtraps/Mojave cams 2022.csv")
carrizo_2022 <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/camtraps/Carrizo cams 2022.csv")
mojave_2023 <- read.csv ("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/camtraps/Mojave cams 2023.csv")
carrizo_2023 <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/camtraps/Carrizo cams 2023.csv")
mojave_winter2023 <-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/camtraps/Mojave cams winter 2023.csv")
carrizo_winter2023 <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/camtraps/Carrizo cams winter 2023.csv")


###calculate capture rate for each site and year from Wildlifeinsight 
### 0.0966% capture rate for Mojave 2022
### 0.0538% capture rate for Mojave 2023 winter
### 1.6% capture rate for Carrizo 2022
### 0.923% capture rate for Carrizo 2023 winter
### 0.19% capture rate for Mojave 2023
### 0.46% capture rate for Carrizo 2023
### Total Observations is species list to make percent proportion plots
### 2022 spring-summer Carrizo
total_observations_carrizo2022 <- carrizo_2022 %>% group_by(scientific_name) %>% summarise(total = sum(animal_hit)) %>% filter(scientific_name != "No CV Result No CV Result")

animals_by_microsite_carrizo2022 <- carrizo_2022 %>% group_by(microsite, scientific_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'microsite'. You can override using the
## `.groups` argument.
microsite_obvs_carrizo2022 <- merge(animals_by_microsite_carrizo2022, total_observations_carrizo2022, all = TRUE)

percent_proportion_carrizo2022<-microsite_obvs_carrizo2022 %>% mutate(percent_proportion = (captures/total)) 

A<-ggplot(percent_proportion_carrizo2022, aes(factor(scientific_name), percent_proportion, fill = microsite)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  theme_classic() +
  xlab("Species") +
  ylab("Relative Proportion") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo Spring 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) 
## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
### 2022 spring-summer Mojave
total_observations_mojave2022<- mojave_2022 %>% group_by(scientific_name) %>% summarise(total = sum(animal_hit)) %>% filter(scientific_name != "No CV Result No CV Result")

animals_by_microsite_mojave2022 <- mojave_2022 %>% group_by(microsite, scientific_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'microsite'. You can override using the
## `.groups` argument.
microsite_obvs_mojave2022 <- merge(animals_by_microsite_mojave2022, total_observations_mojave2022, all = TRUE)

percent_proportion_mojave2022<-microsite_obvs_mojave2022 %>% mutate(percent_proportion = (captures/total)) 


B<-ggplot(percent_proportion_mojave2022, aes(factor(scientific_name), percent_proportion, fill = microsite)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  theme_classic() +
  xlab("Species") +
  ylab("Relative Proportion") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave Spring 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))
### 2023 spring-summer Carrizo
total_observations_carrizo2023 <- carrizo_2023 %>% group_by(scientific_name) %>% summarise(total = sum(animal_hit)) %>% filter(scientific_name != "No CV Result No CV Result")

animals_by_microsite_carrizo2023 <- carrizo_2023 %>% group_by(microsite, scientific_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'microsite'. You can override using the
## `.groups` argument.
microsite_obvs_carrizo2023 <- merge(animals_by_microsite_carrizo2023, total_observations_carrizo2023, all = TRUE)

percent_proportion_carrizo2023<-microsite_obvs_carrizo2023 %>% mutate(percent_proportion = (captures/total)) 

C<-ggplot(percent_proportion_carrizo2023, aes(factor(scientific_name), percent_proportion, fill = microsite)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  theme_classic() +
  xlab("Species") +
  ylab("Relative Proportion") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo Spring 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))

### 2023 spring-summer Mojave
total_observations_mojave2023<- mojave_2023 %>% group_by(scientific_name) %>% summarise(total = sum(animal_hit)) %>% filter(scientific_name != "No CV Result No CV Result")

animals_by_microsite_mojave2023 <- mojave_2023 %>% group_by(microsite, scientific_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'microsite'. You can override using the
## `.groups` argument.
microsite_obvs_mojave2023 <- merge(animals_by_microsite_mojave2023, total_observations_mojave2023, all = TRUE)

percent_proportion_mojave2023<-microsite_obvs_mojave2023 %>% mutate(percent_proportion = (captures/total)) 

D<-ggplot(percent_proportion_mojave2023, aes(factor(scientific_name), percent_proportion, fill = microsite)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  theme_classic() +
  xlab("Species") +
  ylab("Relative Proportion") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave Spring 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))
### 2023 winter Carrizo
total_observations_carrizo2023_winter <- carrizo_winter2023 %>% group_by(scientific_name) %>% summarise(total = sum(animal_hit)) %>% filter(scientific_name != "No CV Result No CV Result")

animals_by_microsite_carrizo2023_winter <- carrizo_winter2023 %>% group_by(microsite, scientific_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'microsite'. You can override using the
## `.groups` argument.
microsite_obvs_carrizo2023_winter <- merge(animals_by_microsite_carrizo2023_winter, total_observations_carrizo2023_winter, all = TRUE)

percent_proportion_carrizo2023_winter<-microsite_obvs_carrizo2023_winter %>% mutate(percent_proportion = (captures/total)) 

E<-ggplot(percent_proportion_carrizo2023_winter, aes(factor(scientific_name), percent_proportion, fill = microsite)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  theme_classic() +
  xlab("Species") +
  ylab("Relative Proportion") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))

### 2023 winter Mojave
total_observations_mojave2023_winter <- mojave_winter2023 %>% group_by(scientific_name) %>% summarise(total = sum(animal_hit)) %>% filter(scientific_name != "No CV Result No CV Result")

animals_by_microsite_mojave2023_winter <- mojave_winter2023 %>% group_by(microsite, scientific_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'microsite'. You can override using the
## `.groups` argument.
microsite_obvs_mojave2023_winter <- merge(animals_by_microsite_mojave2023_winter, total_observations_mojave2023_winter, all = TRUE)

percent_proportion_mojave2023_winter<-microsite_obvs_mojave2023_winter %>% mutate(percent_proportion = (captures/total)) 

F<-ggplot(percent_proportion_mojave2023_winter, aes(factor(scientific_name), percent_proportion, fill = microsite)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  theme_classic() +
  xlab("Species") +
  ylab("Relative Proportion") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))


A/B

C/D

E/F

### PCOA
library(permute)
library(vegan)
## Loading required package: lattice
## This is vegan 2.6-4
library(tidyverse)
library(tidyr)
library(ape)
## 
## Attaching package: 'ape'
## The following object is masked from 'package:dplyr':
## 
##     where
### PCOA Carrizo 2022
pca_data_final_carrizo2022 <-  microsite_obvs_carrizo2022%>%
  spread(scientific_name, captures) %>%
  replace(is.na(.),0)%>% ungroup() %>% dplyr::select(-microsite) 

adonis(pca_data_final_carrizo2022 ~ microsite, data = microsite_obvs_carrizo2022)
## 'adonis' will be deprecated: use 'adonis2' instead
## $aov.tab
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)
## microsite  3    0.3019 0.10062 0.31542 0.03058  0.992
## Residuals 30    9.5703 0.31901         0.96942       
## Total     33    9.8721                 1.00000       
## 
## $call
## adonis(formula = pca_data_final_carrizo2022 ~ microsite, data = microsite_obvs_carrizo2022)
## 
## $coefficients
##                  total Ammospermophilus nelsoni Canis latrans
## (Intercept) 192.145833                7.3680556      1.420139
## microsite1  -59.770833                3.8819444     -1.420139
## microsite2   67.520833               -7.3680556      2.135417
## microsite3   -8.479167               -0.1458333     -1.420139
##             Dipodomys heermanni Dipodomys ingens Dipodomys nelsoni
## (Intercept)            24.89583        10.302083        0.02777778
## microsite1            -24.89583        22.572917       -0.02777778
## microsite2             13.65972        -7.968750       -0.02777778
## microsite3             21.88194        -4.302083        0.08333333
##             Eremophila alpestris Lepus californicus Sylvilagus audubonii
## (Intercept)           0.02777778          2.1076389           0.31597222
## microsite1           -0.02777778          1.5173611           0.05902778
## microsite2           -0.02777778          0.6701389           0.46180556
## microsite3            0.08333333         -1.3298611          -0.20486111
##             Taxidea taxus Vulpes macrotis Xerospermophilus tereticaudus
## (Intercept)       0.09375       1.5069444                    0.05902778
## microsite1        0.03125      -0.2569444                    0.06597222
## microsite2       -0.09375      -0.2847222                    0.05208333
## microsite3       -0.09375       2.0486111                   -0.05902778
## 
## $coef.sites
##                       1             2           3            4           5
## (Intercept)  0.82266066  0.7511841735  0.60392815  0.603227854  0.60062292
## microsite1  -0.06453666 -0.0273964469  0.07373636  0.055148666  0.04437677
## microsite2   0.01845058 -0.0004842814 -0.05799813 -0.043338016 -0.02716873
## microsite3   0.03808407  0.0028563301  0.03187086 -0.005089014  0.01634156
##                       6           7           8            9          10
## (Intercept)  0.66140967  0.65758160  0.75225703  0.881443013  0.79231121
## microsite1  -0.02392882 -0.04404994  0.06041279  0.003160946 -0.05420699
## microsite2   0.05327469  0.01947156 -0.07359020  0.049513677  0.07450031
## microsite3   0.01892447  0.01800510  0.01858545 -0.074476372  0.06120908
##                       11          12           13          14          15
## (Intercept)  0.757975150  0.60232416  0.601659065  0.59665241  0.63171376
## microsite1  -0.033196501  0.07281243  0.054324307  0.04656352 -0.01179151
## microsite2  -0.009136013 -0.05835888 -0.043258895 -0.02730770  0.04341534
## microsite3   0.010708113  0.03059020 -0.003042873  0.01337918  0.02154298
##                      16          17          18          19          20
## (Intercept)  0.64758896  0.74841897  0.82266066  0.79231121  0.77599521
## microsite1  -0.03295851  0.05786472 -0.06453666 -0.05420699 -0.01964839
## microsite2   0.01345977 -0.06858107  0.01845058  0.07450031 -0.03051729
## microsite3   0.02106733  0.02010260  0.03808407  0.06120908  0.01589608
##                      21          22          23          24          25
## (Intercept)  0.61419784  0.61796585  0.62332179  0.64882697  0.67872759
## microsite1   0.07536999  0.05605755  0.02917215 -0.01702150 -0.06828895
## microsite2  -0.05902165 -0.03680169 -0.03196000  0.05291957  0.02593370
## microsite3   0.03524877 -0.01663815  0.02444723  0.01696852  0.02572792
##                      26           27          28          29          30
## (Intercept)  0.75507939  0.881443013  0.79231121  0.64889133  0.60904276
## microsite1   0.06114378  0.003160946 -0.05420699  0.07223656  0.05626707
## microsite2  -0.07428727  0.049513677  0.07450031 -0.06930750 -0.03974522
## microsite3   0.01701317 -0.074476372  0.06120908  0.03718610 -0.01231795
##                      31          32          33            34
## (Intercept)  0.62978120  0.64969741  0.68584857  0.7808930547
## microsite1   0.02439209 -0.01741272 -0.07093279  0.0612287151
## microsite2  -0.02973382  0.05313595  0.02637785 -0.0629854316
## microsite3   0.02527089  0.01731608  0.02652628 -0.0006302245
## 
## $f.perms
##              [,1]
##    [1,] 1.0773695
##    [2,] 1.4346662
##    [3,] 0.7594084
##    [4,] 1.1601047
##    [5,] 0.8139389
##    [6,] 1.8038832
##    [7,] 1.0589874
##    [8,] 1.0809882
##    [9,] 0.9817717
##   [10,] 0.5922997
##   [11,] 0.5875530
##   [12,] 1.6212800
##   [13,] 0.4132547
##   [14,] 0.9439013
##   [15,] 0.8306422
##   [16,] 1.2695341
##   [17,] 1.3394904
##   [18,] 2.2313127
##   [19,] 1.4602037
##   [20,] 0.8874217
##   [21,] 0.8477149
##   [22,] 1.6515857
##   [23,] 0.9209062
##   [24,] 0.8712447
##   [25,] 1.8537751
##   [26,] 0.4520303
##   [27,] 0.6422675
##   [28,] 0.6937360
##   [29,] 0.5121132
##   [30,] 1.0840413
##   [31,] 0.7657220
##   [32,] 0.7407049
##   [33,] 0.7677447
##   [34,] 0.6901325
##   [35,] 0.2217002
##   [36,] 1.1622272
##   [37,] 0.9828825
##   [38,] 0.4115368
##   [39,] 0.9933325
##   [40,] 0.7746668
##   [41,] 0.3400434
##   [42,] 1.3607540
##   [43,] 0.4472123
##   [44,] 1.6264029
##   [45,] 0.7402980
##   [46,] 1.3549384
##   [47,] 0.9120707
##   [48,] 1.7390446
##   [49,] 0.7622935
##   [50,] 0.4642489
##   [51,] 0.8490542
##   [52,] 1.1438176
##   [53,] 1.2062347
##   [54,] 0.8989609
##   [55,] 0.2607377
##   [56,] 0.8648469
##   [57,] 2.3619086
##   [58,] 0.8546718
##   [59,] 1.5722175
##   [60,] 0.5108489
##   [61,] 1.3309682
##   [62,] 0.6979797
##   [63,] 0.9862426
##   [64,] 1.8253666
##   [65,] 0.7039515
##   [66,] 2.4290442
##   [67,] 1.0625229
##   [68,] 0.8640515
##   [69,] 1.0907585
##   [70,] 1.1749779
##   [71,] 1.6721614
##   [72,] 0.9708889
##   [73,] 0.5143696
##   [74,] 1.1078374
##   [75,] 0.5750246
##   [76,] 1.1329288
##   [77,] 1.1576832
##   [78,] 1.2298644
##   [79,] 1.0169410
##   [80,] 0.4011755
##   [81,] 1.0734196
##   [82,] 0.4977247
##   [83,] 1.9842955
##   [84,] 0.5237694
##   [85,] 0.4788469
##   [86,] 0.5318913
##   [87,] 0.9376171
##   [88,] 1.0651569
##   [89,] 1.3502565
##   [90,] 0.5894219
##   [91,] 0.8905804
##   [92,] 2.0533064
##   [93,] 0.9410248
##   [94,] 0.5897965
##   [95,] 1.0501578
##   [96,] 1.3987373
##   [97,] 0.9855457
##   [98,] 1.1086486
##   [99,] 0.5013632
##  [100,] 0.5446618
##  [101,] 0.5710572
##  [102,] 0.8241510
##  [103,] 1.9371325
##  [104,] 0.8340133
##  [105,] 0.6581928
##  [106,] 1.1945682
##  [107,] 0.8162550
##  [108,] 0.9284143
##  [109,] 1.3671057
##  [110,] 0.5741838
##  [111,] 0.8438246
##  [112,] 1.8252784
##  [113,] 0.8199549
##  [114,] 0.9219512
##  [115,] 0.9635522
##  [116,] 1.0228218
##  [117,] 1.0043853
##  [118,] 0.5581192
##  [119,] 1.2178961
##  [120,] 1.7275631
##  [121,] 0.5337335
##  [122,] 1.1932273
##  [123,] 0.7436823
##  [124,] 0.3348509
##  [125,] 1.3205523
##  [126,] 1.5482372
##  [127,] 0.4907302
##  [128,] 0.9291597
##  [129,] 0.8111345
##  [130,] 0.8999173
##  [131,] 0.7730638
##  [132,] 0.6917351
##  [133,] 0.9359345
##  [134,] 1.3238360
##  [135,] 0.9405476
##  [136,] 1.2037680
##  [137,] 0.6459283
##  [138,] 0.6917776
##  [139,] 1.8892990
##  [140,] 1.6743325
##  [141,] 0.5112099
##  [142,] 1.3450152
##  [143,] 0.7823561
##  [144,] 0.7483766
##  [145,] 0.4285560
##  [146,] 0.6800580
##  [147,] 0.7163132
##  [148,] 3.3104624
##  [149,] 0.6794660
##  [150,] 1.0430674
##  [151,] 1.4759836
##  [152,] 0.8442450
##  [153,] 0.7198996
##  [154,] 1.3142312
##  [155,] 1.7408914
##  [156,] 1.2148176
##  [157,] 0.9990606
##  [158,] 0.6137924
##  [159,] 1.3734379
##  [160,] 1.2646388
##  [161,] 1.4897055
##  [162,] 0.8499780
##  [163,] 2.6170316
##  [164,] 0.6517809
##  [165,] 0.9256920
##  [166,] 1.0475426
##  [167,] 1.6999764
##  [168,] 0.9324713
##  [169,] 1.6867151
##  [170,] 0.3982554
##  [171,] 1.3206805
##  [172,] 1.3555704
##  [173,] 0.3887953
##  [174,] 0.4624891
##  [175,] 0.4486391
##  [176,] 1.3802087
##  [177,] 1.8042189
##  [178,] 1.2726028
##  [179,] 0.5112027
##  [180,] 0.8814058
##  [181,] 0.4707463
##  [182,] 1.3062912
##  [183,] 0.5901703
##  [184,] 0.7645781
##  [185,] 0.6730904
##  [186,] 0.5202965
##  [187,] 1.1969601
##  [188,] 1.7979016
##  [189,] 0.8290130
##  [190,] 0.5345689
##  [191,] 0.9205430
##  [192,] 2.5646463
##  [193,] 0.9192182
##  [194,] 1.0023936
##  [195,] 1.3263514
##  [196,] 0.7593473
##  [197,] 1.3850690
##  [198,] 0.9044589
##  [199,] 0.4761108
##  [200,] 1.7232842
##  [201,] 1.4049950
##  [202,] 1.5809669
##  [203,] 1.1560883
##  [204,] 1.3779510
##  [205,] 0.8539367
##  [206,] 0.4735716
##  [207,] 0.3525171
##  [208,] 2.3191742
##  [209,] 0.8168767
##  [210,] 0.8504346
##  [211,] 0.8420970
##  [212,] 1.7265849
##  [213,] 1.2582063
##  [214,] 0.7861470
##  [215,] 2.0592438
##  [216,] 0.8818760
##  [217,] 1.3166893
##  [218,] 0.7638063
##  [219,] 0.7236693
##  [220,] 0.6682102
##  [221,] 1.4194424
##  [222,] 1.1727070
##  [223,] 0.9862615
##  [224,] 1.4621432
##  [225,] 0.4092260
##  [226,] 1.9334518
##  [227,] 1.4422665
##  [228,] 1.7354266
##  [229,] 0.8257635
##  [230,] 2.3925984
##  [231,] 1.0694065
##  [232,] 1.3108524
##  [233,] 0.7150875
##  [234,] 0.6283255
##  [235,] 0.7143620
##  [236,] 0.5379952
##  [237,] 0.6901832
##  [238,] 0.9484795
##  [239,] 0.8492347
##  [240,] 0.9017705
##  [241,] 0.4464448
##  [242,] 0.8939154
##  [243,] 1.4376909
##  [244,] 0.7134428
##  [245,] 0.7742249
##  [246,] 0.7828549
##  [247,] 1.4874285
##  [248,] 0.4781466
##  [249,] 1.5274064
##  [250,] 0.4649723
##  [251,] 1.1349872
##  [252,] 1.0911615
##  [253,] 0.7319726
##  [254,] 1.5135241
##  [255,] 0.9325407
##  [256,] 1.0507885
##  [257,] 0.8223239
##  [258,] 0.4047382
##  [259,] 1.8642744
##  [260,] 1.5694074
##  [261,] 1.1601954
##  [262,] 0.7317296
##  [263,] 1.3987564
##  [264,] 0.8231764
##  [265,] 0.9367926
##  [266,] 1.4238097
##  [267,] 0.7063184
##  [268,] 0.8527986
##  [269,] 1.3894746
##  [270,] 1.0897926
##  [271,] 1.6188602
##  [272,] 1.3788448
##  [273,] 0.6701324
##  [274,] 0.6760699
##  [275,] 0.7398220
##  [276,] 0.8171299
##  [277,] 0.3122915
##  [278,] 1.2406707
##  [279,] 0.6290855
##  [280,] 1.1339458
##  [281,] 0.6329586
##  [282,] 0.7592386
##  [283,] 0.7162547
##  [284,] 0.6947016
##  [285,] 1.7376601
##  [286,] 0.4466565
##  [287,] 1.0789976
##  [288,] 1.2225583
##  [289,] 0.4918717
##  [290,] 0.7552068
##  [291,] 1.0812149
##  [292,] 0.5571945
##  [293,] 1.1066098
##  [294,] 0.5440910
##  [295,] 1.4263977
##  [296,] 1.2664312
##  [297,] 1.4783245
##  [298,] 0.5217713
##  [299,] 1.4450267
##  [300,] 0.5954340
##  [301,] 0.8658567
##  [302,] 0.5193915
##  [303,] 0.6622077
##  [304,] 1.1308273
##  [305,] 0.4420077
##  [306,] 0.9521207
##  [307,] 0.6197900
##  [308,] 0.7634020
##  [309,] 0.3001198
##  [310,] 1.3947193
##  [311,] 0.9328377
##  [312,] 0.8429804
##  [313,] 0.6893952
##  [314,] 0.7883077
##  [315,] 1.3294775
##  [316,] 1.0244386
##  [317,] 0.7167139
##  [318,] 0.7659235
##  [319,] 0.7860069
##  [320,] 0.5191701
##  [321,] 0.6689067
##  [322,] 1.1480346
##  [323,] 1.0209018
##  [324,] 0.5909199
##  [325,] 0.6496004
##  [326,] 1.6307997
##  [327,] 0.7130731
##  [328,] 0.8575562
##  [329,] 1.4407009
##  [330,] 0.5839084
##  [331,] 0.9619034
##  [332,] 0.6518316
##  [333,] 0.5588785
##  [334,] 0.8413745
##  [335,] 0.8215909
##  [336,] 0.8114406
##  [337,] 0.9159978
##  [338,] 0.9226247
##  [339,] 1.2373040
##  [340,] 0.9457736
##  [341,] 1.1307082
##  [342,] 1.3795613
##  [343,] 0.5449711
##  [344,] 1.3513279
##  [345,] 1.1609233
##  [346,] 0.9638608
##  [347,] 0.4767717
##  [348,] 1.0751451
##  [349,] 0.7298253
##  [350,] 0.5061450
##  [351,] 0.6230437
##  [352,] 1.0121625
##  [353,] 0.5611648
##  [354,] 0.7239393
##  [355,] 0.8424636
##  [356,] 0.8642951
##  [357,] 1.1033719
##  [358,] 0.6468763
##  [359,] 0.5160954
##  [360,] 0.4874431
##  [361,] 1.4605699
##  [362,] 1.2526932
##  [363,] 0.6584695
##  [364,] 0.9726520
##  [365,] 0.4883252
##  [366,] 1.6093449
##  [367,] 0.4511070
##  [368,] 1.5014235
##  [369,] 0.9561763
##  [370,] 0.6253064
##  [371,] 0.7452576
##  [372,] 0.9912204
##  [373,] 0.4256464
##  [374,] 1.3145237
##  [375,] 0.9976531
##  [376,] 0.8349534
##  [377,] 0.9060387
##  [378,] 0.6709793
##  [379,] 0.7431739
##  [380,] 0.6993158
##  [381,] 1.3539494
##  [382,] 1.4785618
##  [383,] 0.6914178
##  [384,] 0.7599161
##  [385,] 0.9907293
##  [386,] 0.7327148
##  [387,] 0.5514533
##  [388,] 1.9612114
##  [389,] 1.0679948
##  [390,] 1.0297828
##  [391,] 0.7615512
##  [392,] 0.4720129
##  [393,] 0.4444803
##  [394,] 0.9053966
##  [395,] 0.5179637
##  [396,] 0.9826467
##  [397,] 0.5002681
##  [398,] 1.0998246
##  [399,] 0.5974834
##  [400,] 0.6597246
##  [401,] 1.1763690
##  [402,] 0.3926508
##  [403,] 1.1860980
##  [404,] 0.6369856
##  [405,] 1.2823038
##  [406,] 0.8947984
##  [407,] 1.3209745
##  [408,] 0.5031699
##  [409,] 1.0898952
##  [410,] 2.5719792
##  [411,] 1.9263604
##  [412,] 0.4985209
##  [413,] 1.2652751
##  [414,] 0.9056110
##  [415,] 0.5074541
##  [416,] 0.8108219
##  [417,] 0.9874037
##  [418,] 0.6865818
##  [419,] 1.2299029
##  [420,] 0.5402754
##  [421,] 0.3686988
##  [422,] 1.5954782
##  [423,] 0.7402526
##  [424,] 0.6832599
##  [425,] 0.5446324
##  [426,] 0.8607116
##  [427,] 1.4409429
##  [428,] 1.4902969
##  [429,] 0.9801575
##  [430,] 0.7842497
##  [431,] 1.2430979
##  [432,] 0.4367563
##  [433,] 0.7341196
##  [434,] 0.8372535
##  [435,] 1.0216806
##  [436,] 0.4787990
##  [437,] 1.4407344
##  [438,] 1.2747062
##  [439,] 0.5750868
##  [440,] 1.0194846
##  [441,] 1.3645178
##  [442,] 0.6608412
##  [443,] 1.1081155
##  [444,] 0.7165020
##  [445,] 0.6551358
##  [446,] 0.9169156
##  [447,] 0.9304830
##  [448,] 0.8543710
##  [449,] 1.9253044
##  [450,] 0.8727734
##  [451,] 1.5285397
##  [452,] 1.4724122
##  [453,] 0.8132872
##  [454,] 1.3140953
##  [455,] 0.7794207
##  [456,] 1.2191714
##  [457,] 0.3768440
##  [458,] 1.2975716
##  [459,] 0.8360738
##  [460,] 0.5281169
##  [461,] 1.1190625
##  [462,] 0.7916934
##  [463,] 0.8844438
##  [464,] 1.2061066
##  [465,] 1.6584223
##  [466,] 0.8266564
##  [467,] 1.1221912
##  [468,] 1.1065249
##  [469,] 1.9567344
##  [470,] 0.9478692
##  [471,] 1.3357984
##  [472,] 1.4833566
##  [473,] 0.6826449
##  [474,] 0.7361561
##  [475,] 1.2057754
##  [476,] 1.1866465
##  [477,] 0.4110518
##  [478,] 1.5438773
##  [479,] 1.6763325
##  [480,] 0.7347509
##  [481,] 1.0198853
##  [482,] 0.6106163
##  [483,] 1.4273591
##  [484,] 0.8054483
##  [485,] 0.9852284
##  [486,] 1.3950462
##  [487,] 0.6334865
##  [488,] 1.4491804
##  [489,] 0.8646103
##  [490,] 0.5322090
##  [491,] 0.3949340
##  [492,] 1.4235567
##  [493,] 1.3530908
##  [494,] 1.2807370
##  [495,] 0.8854192
##  [496,] 0.6495914
##  [497,] 0.7026357
##  [498,] 0.7000747
##  [499,] 1.3689984
##  [500,] 0.5321743
##  [501,] 0.8493609
##  [502,] 1.5094457
##  [503,] 1.0176251
##  [504,] 1.6939629
##  [505,] 0.7514144
##  [506,] 0.8238949
##  [507,] 1.1407945
##  [508,] 0.4876222
##  [509,] 0.6953776
##  [510,] 0.4145535
##  [511,] 0.7664069
##  [512,] 0.7775866
##  [513,] 0.8922998
##  [514,] 0.3997017
##  [515,] 1.3215761
##  [516,] 0.8978755
##  [517,] 1.3000704
##  [518,] 1.3638910
##  [519,] 0.9223576
##  [520,] 1.5335349
##  [521,] 0.5885803
##  [522,] 0.8241975
##  [523,] 1.2110133
##  [524,] 1.2546273
##  [525,] 0.7472806
##  [526,] 1.2953039
##  [527,] 1.3263949
##  [528,] 0.4344457
##  [529,] 0.8937527
##  [530,] 0.9513223
##  [531,] 1.2471957
##  [532,] 1.3674966
##  [533,] 0.3499745
##  [534,] 1.2385021
##  [535,] 1.0157385
##  [536,] 1.6871995
##  [537,] 0.7713435
##  [538,] 1.5436637
##  [539,] 0.7695756
##  [540,] 1.1763866
##  [541,] 0.7368207
##  [542,] 2.5887590
##  [543,] 1.4238927
##  [544,] 1.4590054
##  [545,] 0.6493384
##  [546,] 1.4330446
##  [547,] 1.1709218
##  [548,] 1.2550778
##  [549,] 0.4615182
##  [550,] 0.9885323
##  [551,] 1.2008613
##  [552,] 0.8517406
##  [553,] 1.5523855
##  [554,] 3.5934189
##  [555,] 0.3743167
##  [556,] 0.9131706
##  [557,] 0.9041413
##  [558,] 1.3086484
##  [559,] 0.8173702
##  [560,] 0.4166316
##  [561,] 0.8633192
##  [562,] 0.9354215
##  [563,] 2.0595112
##  [564,] 0.6145882
##  [565,] 0.9786149
##  [566,] 2.2317597
##  [567,] 0.5369958
##  [568,] 0.9083455
##  [569,] 0.4070768
##  [570,] 1.2748043
##  [571,] 0.5150598
##  [572,] 1.9520967
##  [573,] 0.6313868
##  [574,] 1.1421134
##  [575,] 0.2912333
##  [576,] 1.3794032
##  [577,] 1.6470648
##  [578,] 1.3498154
##  [579,] 0.9748367
##  [580,] 0.6725919
##  [581,] 1.0329795
##  [582,] 0.6842986
##  [583,] 0.4690475
##  [584,] 0.5824117
##  [585,] 0.9325214
##  [586,] 0.6823660
##  [587,] 0.4872774
##  [588,] 0.7942603
##  [589,] 0.4181393
##  [590,] 1.1028652
##  [591,] 0.8051048
##  [592,] 1.4458881
##  [593,] 1.8688985
##  [594,] 0.4443978
##  [595,] 0.2803239
##  [596,] 0.8666339
##  [597,] 2.1522813
##  [598,] 0.9084208
##  [599,] 0.9714052
##  [600,] 2.0474789
##  [601,] 0.6220264
##  [602,] 0.2966183
##  [603,] 0.9502217
##  [604,] 0.6662445
##  [605,] 1.1349584
##  [606,] 0.4548888
##  [607,] 0.7948620
##  [608,] 0.8204299
##  [609,] 0.9218675
##  [610,] 0.8576691
##  [611,] 0.8756354
##  [612,] 1.0206901
##  [613,] 0.9164971
##  [614,] 1.5536442
##  [615,] 1.0606556
##  [616,] 1.2948543
##  [617,] 1.4896063
##  [618,] 0.6305859
##  [619,] 1.1262893
##  [620,] 2.0621399
##  [621,] 0.5738172
##  [622,] 0.8605702
##  [623,] 1.1439592
##  [624,] 1.1560719
##  [625,] 0.6265339
##  [626,] 0.6826943
##  [627,] 0.6568833
##  [628,] 0.8602155
##  [629,] 0.9427119
##  [630,] 2.0741950
##  [631,] 1.1909912
##  [632,] 0.8227922
##  [633,] 1.4112212
##  [634,] 0.7578673
##  [635,] 1.5846384
##  [636,] 0.6179752
##  [637,] 1.9514079
##  [638,] 1.1890444
##  [639,] 0.9809535
##  [640,] 2.0609680
##  [641,] 0.7251875
##  [642,] 1.3748843
##  [643,] 0.8568114
##  [644,] 1.8384047
##  [645,] 0.9503724
##  [646,] 0.9604371
##  [647,] 1.4200314
##  [648,] 0.6959133
##  [649,] 0.7981805
##  [650,] 0.6220709
##  [651,] 0.8875175
##  [652,] 0.9777951
##  [653,] 0.5566346
##  [654,] 0.7511426
##  [655,] 1.5986240
##  [656,] 0.9963527
##  [657,] 0.3191437
##  [658,] 0.7227692
##  [659,] 0.8456685
##  [660,] 0.9019765
##  [661,] 1.1667308
##  [662,] 1.2584891
##  [663,] 0.5361386
##  [664,] 1.2845537
##  [665,] 0.9018246
##  [666,] 0.7228494
##  [667,] 0.8308384
##  [668,] 0.7281039
##  [669,] 0.8753937
##  [670,] 0.9245299
##  [671,] 0.5128281
##  [672,] 1.7995776
##  [673,] 0.3672249
##  [674,] 0.4822429
##  [675,] 0.5841772
##  [676,] 0.6001585
##  [677,] 0.3550764
##  [678,] 0.9208211
##  [679,] 0.6174704
##  [680,] 0.9107203
##  [681,] 1.0421145
##  [682,] 1.6113880
##  [683,] 1.2435253
##  [684,] 0.8310720
##  [685,] 1.1762702
##  [686,] 0.5523803
##  [687,] 2.8850048
##  [688,] 1.1222560
##  [689,] 1.0855993
##  [690,] 1.5120531
##  [691,] 1.6443483
##  [692,] 0.6193301
##  [693,] 1.4292422
##  [694,] 0.9382810
##  [695,] 2.0269668
##  [696,] 1.6179742
##  [697,] 0.6530875
##  [698,] 0.5862077
##  [699,] 1.9013970
##  [700,] 0.8825201
##  [701,] 1.1272764
##  [702,] 1.5600752
##  [703,] 1.4124103
##  [704,] 0.9531044
##  [705,] 2.1681583
##  [706,] 1.3474809
##  [707,] 1.5341011
##  [708,] 0.9841912
##  [709,] 0.8109382
##  [710,] 0.7026981
##  [711,] 0.7339728
##  [712,] 0.5839135
##  [713,] 1.2208915
##  [714,] 0.8596577
##  [715,] 0.6553230
##  [716,] 0.5022358
##  [717,] 1.2587239
##  [718,] 1.0139180
##  [719,] 1.1613946
##  [720,] 0.6652132
##  [721,] 1.4776826
##  [722,] 1.5873430
##  [723,] 0.5753276
##  [724,] 2.0868245
##  [725,] 1.1485471
##  [726,] 0.9958265
##  [727,] 0.6899987
##  [728,] 2.2528227
##  [729,] 1.1024463
##  [730,] 0.5420490
##  [731,] 0.8182847
##  [732,] 0.5834584
##  [733,] 1.4973480
##  [734,] 0.6122164
##  [735,] 1.8157109
##  [736,] 0.7962185
##  [737,] 0.7158108
##  [738,] 0.6219141
##  [739,] 1.2223288
##  [740,] 1.1240932
##  [741,] 0.5193779
##  [742,] 1.2392263
##  [743,] 0.9693371
##  [744,] 1.4946395
##  [745,] 0.8662575
##  [746,] 0.5961018
##  [747,] 0.7274359
##  [748,] 0.7871096
##  [749,] 1.1802359
##  [750,] 0.5493467
##  [751,] 2.2076147
##  [752,] 1.4172794
##  [753,] 0.6461132
##  [754,] 0.7573343
##  [755,] 0.9144911
##  [756,] 1.7014579
##  [757,] 1.4768235
##  [758,] 1.1448810
##  [759,] 0.6368110
##  [760,] 1.2091052
##  [761,] 0.9746678
##  [762,] 0.6702309
##  [763,] 0.8738416
##  [764,] 0.7653304
##  [765,] 0.7073554
##  [766,] 0.6196319
##  [767,] 2.6317603
##  [768,] 1.2990053
##  [769,] 0.6944033
##  [770,] 1.4537482
##  [771,] 1.1728138
##  [772,] 0.8679113
##  [773,] 0.6451986
##  [774,] 0.7786661
##  [775,] 2.2927670
##  [776,] 0.6400282
##  [777,] 0.8587385
##  [778,] 0.6136302
##  [779,] 0.9895709
##  [780,] 0.5714818
##  [781,] 1.4174354
##  [782,] 0.8281998
##  [783,] 0.6666572
##  [784,] 0.6524376
##  [785,] 1.5394113
##  [786,] 0.8238446
##  [787,] 0.4673017
##  [788,] 1.8059462
##  [789,] 1.4571002
##  [790,] 0.9443167
##  [791,] 0.7095452
##  [792,] 0.7171664
##  [793,] 1.1914854
##  [794,] 1.4960412
##  [795,] 1.0333179
##  [796,] 0.8925537
##  [797,] 1.8960014
##  [798,] 1.2048326
##  [799,] 1.0247631
##  [800,] 0.4225875
##  [801,] 0.5526026
##  [802,] 0.8554193
##  [803,] 1.3202118
##  [804,] 1.2279310
##  [805,] 0.6434641
##  [806,] 0.8604223
##  [807,] 1.0285229
##  [808,] 0.6400247
##  [809,] 0.7920109
##  [810,] 0.7957595
##  [811,] 0.6117581
##  [812,] 0.9850369
##  [813,] 0.4047078
##  [814,] 0.8940065
##  [815,] 1.0364845
##  [816,] 0.4897637
##  [817,] 1.1075902
##  [818,] 0.7614939
##  [819,] 0.6199301
##  [820,] 0.9008478
##  [821,] 0.7372797
##  [822,] 0.9388884
##  [823,] 0.6135065
##  [824,] 1.9877185
##  [825,] 0.2613737
##  [826,] 1.4184004
##  [827,] 1.5170672
##  [828,] 1.2107030
##  [829,] 1.7459620
##  [830,] 1.0358410
##  [831,] 2.1937910
##  [832,] 1.0471809
##  [833,] 1.3115104
##  [834,] 0.8454892
##  [835,] 0.9874421
##  [836,] 0.7668087
##  [837,] 1.0840083
##  [838,] 0.8334079
##  [839,] 1.7860703
##  [840,] 0.7003025
##  [841,] 1.5002657
##  [842,] 1.5520670
##  [843,] 1.1306178
##  [844,] 0.4847466
##  [845,] 1.2715126
##  [846,] 1.2755549
##  [847,] 0.8835020
##  [848,] 1.1080677
##  [849,] 0.5939677
##  [850,] 1.1890934
##  [851,] 1.0851402
##  [852,] 0.9380848
##  [853,] 0.9290391
##  [854,] 0.8494418
##  [855,] 0.8490140
##  [856,] 1.7058720
##  [857,] 1.2384688
##  [858,] 0.4787935
##  [859,] 1.3181438
##  [860,] 0.9047320
##  [861,] 0.9720074
##  [862,] 0.9155160
##  [863,] 1.8422746
##  [864,] 0.6340879
##  [865,] 0.4514208
##  [866,] 0.9132408
##  [867,] 1.0695275
##  [868,] 1.0737857
##  [869,] 1.4497503
##  [870,] 0.7823452
##  [871,] 1.0002516
##  [872,] 0.7719286
##  [873,] 1.2365877
##  [874,] 0.7158875
##  [875,] 1.5026070
##  [876,] 0.7369098
##  [877,] 0.9461444
##  [878,] 0.7148361
##  [879,] 0.9596817
##  [880,] 0.7709302
##  [881,] 1.3635047
##  [882,] 1.2052413
##  [883,] 1.0801804
##  [884,] 1.6559004
##  [885,] 0.6215183
##  [886,] 1.7710222
##  [887,] 1.2806624
##  [888,] 0.8678510
##  [889,] 1.7330749
##  [890,] 0.6868303
##  [891,] 1.2925470
##  [892,] 0.9664803
##  [893,] 0.9796046
##  [894,] 1.1030750
##  [895,] 0.7164531
##  [896,] 0.6111044
##  [897,] 0.6306393
##  [898,] 0.5249276
##  [899,] 1.0624563
##  [900,] 0.7235598
##  [901,] 0.9892878
##  [902,] 1.9505599
##  [903,] 0.8536337
##  [904,] 0.6731660
##  [905,] 0.4974900
##  [906,] 0.9846212
##  [907,] 2.5072106
##  [908,] 2.0377057
##  [909,] 0.4914008
##  [910,] 1.1518360
##  [911,] 0.7776633
##  [912,] 0.7439179
##  [913,] 0.6711736
##  [914,] 1.2500942
##  [915,] 0.7568076
##  [916,] 0.8300713
##  [917,] 1.5229156
##  [918,] 0.5207446
##  [919,] 1.4177845
##  [920,] 1.1572261
##  [921,] 1.3030444
##  [922,] 0.6994236
##  [923,] 1.0740906
##  [924,] 0.8632824
##  [925,] 0.4944589
##  [926,] 0.8040111
##  [927,] 1.4844070
##  [928,] 1.3442823
##  [929,] 0.6834972
##  [930,] 0.4704407
##  [931,] 1.0553523
##  [932,] 0.9393368
##  [933,] 1.1296679
##  [934,] 1.0434323
##  [935,] 0.5171811
##  [936,] 0.8794741
##  [937,] 0.9776885
##  [938,] 0.6588200
##  [939,] 0.5556803
##  [940,] 0.4415477
##  [941,] 1.1151609
##  [942,] 0.6325285
##  [943,] 1.2351915
##  [944,] 0.9268118
##  [945,] 0.6679873
##  [946,] 0.7900747
##  [947,] 1.6985406
##  [948,] 0.5843778
##  [949,] 0.7277993
##  [950,] 1.8579563
##  [951,] 1.5994954
##  [952,] 1.3758466
##  [953,] 0.8298203
##  [954,] 0.8364771
##  [955,] 1.8116026
##  [956,] 0.9164043
##  [957,] 1.1747654
##  [958,] 0.5799742
##  [959,] 1.0400606
##  [960,] 0.5294579
##  [961,] 0.8607796
##  [962,] 0.6590123
##  [963,] 0.9132961
##  [964,] 0.8652726
##  [965,] 0.9070996
##  [966,] 0.6703851
##  [967,] 0.5581117
##  [968,] 0.9302870
##  [969,] 0.9769511
##  [970,] 1.2399394
##  [971,] 1.3126874
##  [972,] 0.5166795
##  [973,] 0.8667119
##  [974,] 0.8244645
##  [975,] 1.2707546
##  [976,] 0.4764990
##  [977,] 0.9576390
##  [978,] 0.6026171
##  [979,] 0.4451594
##  [980,] 0.7651295
##  [981,] 0.6343524
##  [982,] 1.0795462
##  [983,] 0.6733967
##  [984,] 1.2230154
##  [985,] 0.6298828
##  [986,] 1.4182619
##  [987,] 1.1835089
##  [988,] 1.1506621
##  [989,] 1.2784158
##  [990,] 0.5309505
##  [991,] 1.7040299
##  [992,] 1.3783083
##  [993,] 0.6969415
##  [994,] 0.5355270
##  [995,] 0.6340151
##  [996,] 0.8906703
##  [997,] 0.4760332
##  [998,] 1.4672961
##  [999,] 1.7217013
## 
## $model.matrix
##    (Intercept) microsite1 microsite2 microsite3
## 1            1          1          0          0
## 2            1          0          0          1
## 3            1         -1         -1         -1
## 4            1          0          1          0
## 5            1         -1         -1         -1
## 6            1          1          0          0
## 7            1          0          0          1
## 8            1          0          1          0
## 9            1          0          0          1
## 10           1         -1         -1         -1
## 11           1          1          0          0
## 12           1          0          1          0
## 13           1          1          0          0
## 14           1          0          0          1
## 15           1         -1         -1         -1
## 16           1          0          1          0
## 17           1         -1         -1         -1
## 18           1          0          1          0
## 19           1          1          0          0
## 20           1          0          1          0
## 21           1         -1         -1         -1
## 22           1          0          0          1
## 23           1          0          1          0
## 24           1          0          0          1
## 25           1          1          0          0
## 26           1          0          1          0
## 27           1          0          0          1
## 28           1         -1         -1         -1
## 29           1          0          1          0
## 30           1          0          0          1
## 31           1          1          0          0
## 32           1         -1         -1         -1
## 33           1          1          0          0
## 34           1          0          0          1
## 
## $terms
## pca_data_final_carrizo2022 ~ microsite
## attr(,"variables")
## list(pca_data_final_carrizo2022, microsite)
## attr(,"factors")
##                            microsite
## pca_data_final_carrizo2022         0
## microsite                          1
## attr(,"term.labels")
## [1] "microsite"
## attr(,"order")
## [1] 1
## attr(,"intercept")
## [1] 1
## attr(,"response")
## [1] 1
## attr(,".Environment")
## <environment: R_GlobalEnv>
## 
## attr(,"class")
## [1] "adonis"
dist_final_carrizo2022<-vegdist(pca_data_final_carrizo2022, species = "bray")
res_final_carrizo2022<-pcoa(dist_final_carrizo2022)

p01_carrizo2022 <- as.data.frame(res_final_carrizo2022$vectors)%>%
  dplyr::select(Axis.1, Axis.2) %>% bind_cols(microsite_obvs_carrizo2022)


ggplot() + 
  geom_point(data = p01_carrizo2022, aes(x = Axis.1, y = Axis.2, color = microsite))+ theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ labs(color = "Microsite") + ggtitle('Carrizo 2022')

model1<-betadisper(dist_final_carrizo2022, microsite_obvs_carrizo2022$microsite)

anova(model1)
## Analysis of Variance Table
## 
## Response: Distances
##           Df  Sum Sq   Mean Sq F value Pr(>F)
## Groups     3 0.00897 0.0029912  0.1016 0.9585
## Residuals 30 0.88327 0.0294423
TukeyHSD(model1)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = distances ~ group, data = df)
## 
## $group
##                                      diff        lwr       upr     p adj
## open-Ephedra californica     -0.027085276 -0.2537954 0.1996248 0.9879161
## square-Ephedra californica    0.006470569 -0.2202396 0.2331807 0.9998284
## triangle-Ephedra californica -0.030425515 -0.2637083 0.2028573 0.9844077
## square-open                   0.033555845 -0.1863853 0.2534970 0.9755051
## triangle-open                -0.003340240 -0.2300504 0.2233699 0.9999763
## triangle-square              -0.036896085 -0.2636062 0.1898140 0.9705518
permutest(model1, pairwise = TRUE)
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df  Sum Sq   Mean Sq      F N.Perm Pr(>F)
## Groups     3 0.00897 0.0029912 0.1016    999  0.955
## Residuals 30 0.88327 0.0294423                     
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##                     Ephedra californica    open  square triangle
## Ephedra californica                     0.76200 0.92600    0.680
## open                            0.74985         0.71000    0.969
## square                          0.92799 0.71272            0.648
## triangle                        0.68695 0.97229 0.66433
boxplot(model1, xlab = "Microsite")

### PCOA Carrizo 2023
pca_data_final_carrizo2023 <-  microsite_obvs_carrizo2023%>%
  spread(scientific_name, captures) %>% dplyr::select(-microsite) %>%
  replace(is.na(.),0) %>% ungroup

dist_final_carrizo2023<-vegdist(pca_data_final_carrizo2023, species = "bray")
res_final_carrizo2023<-pcoa(dist_final_carrizo2023)

###make the rows equal manually
microsite_obvs_carrizo2023_new <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/microsite_obvs_carrizo2023_new.csv")

p01_carrizo2023 <- as.data.frame(res_final_carrizo2023$vectors)%>%
  dplyr::select(Axis.1, Axis.2) %>% bind_cols(microsite_obvs_carrizo2023_new)


ggplot() + 
  geom_point(data = p01_carrizo2023, aes(x = Axis.1, y = Axis.2, color = microsite))+ theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ labs(color = "Microsite")+ ggtitle('Carrizo 2023')

model2<-betadisper(dist_final_carrizo2023, microsite_obvs_carrizo2023_new$microsite)

anova(model2)
## Analysis of Variance Table
## 
## Response: Distances
##           Df  Sum Sq  Mean Sq F value Pr(>F)
## Groups     3 0.03357 0.011189  0.2708 0.8457
## Residuals 22 0.90887 0.041312
TukeyHSD(model2)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = distances ~ group, data = df)
## 
## $group
##                                     diff        lwr       upr     p adj
## open-Ephedra californica      0.11612610 -0.2481943 0.4804465 0.8125365
## square-Ephedra californica    0.05797616 -0.2957820 0.4117343 0.9679262
## triangle-Ephedra californica  0.07527587 -0.2638880 0.4144397 0.9257820
## square-open                  -0.05814995 -0.3721547 0.2558548 0.9548066
## triangle-open                -0.04085024 -0.3383166 0.2566161 0.9806383
## triangle-square               0.01729971 -0.2671325 0.3017320 0.9982330
permutest(model2, pairwise = TRUE)
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df  Sum Sq  Mean Sq      F N.Perm Pr(>F)
## Groups     3 0.03357 0.011189 0.2708    999  0.834
## Residuals 22 0.90887 0.041312                     
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##                     Ephedra californica    open  square triangle
## Ephedra californica                     0.44600 0.72500    0.600
## open                            0.44743         0.55000    0.615
## square                          0.72438 0.55446            0.850
## triangle                        0.59801 0.63328 0.85891
boxplot(model2, xlab = "Microsite")

### PCOA Carrizo Winter 2023

pca_data_final_carrizo2023_winter <-  microsite_obvs_carrizo2023_winter%>%
  spread(scientific_name, captures) %>%
  replace(is.na(.),0)%>% ungroup() %>% dplyr::select(-microsite) 

dist_final_carrizo2023_winter<-vegdist(pca_data_final_carrizo2023_winter, species = "bray")
res_final_carrizo2023_winter<-pcoa(dist_final_carrizo2023_winter)

###make the rows equal manually

microsite_obvs_carrizo2023_winter_new <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/microsite_obvs_carrizo2023_winter_new.csv")

p01_carrizo2023_winter <- as.data.frame(res_final_carrizo2023_winter$vectors)%>%
  dplyr::select(Axis.1, Axis.2) %>% bind_cols(microsite_obvs_carrizo2023_winter_new)


ggplot() + 
  geom_point(data = p01_carrizo2023_winter, aes(x = Axis.1, y = Axis.2, color = microsite))+ theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ labs(color = "Microsite") + ggtitle('Carrizo Winter 2023')

model3<-betadisper(dist_final_carrizo2023_winter, microsite_obvs_carrizo2023_winter_new$microsite)

anova(model3)
## Analysis of Variance Table
## 
## Response: Distances
##           Df  Sum Sq  Mean Sq F value Pr(>F)
## Groups     2 0.05652 0.028259  0.4183 0.6662
## Residuals 14 0.94590 0.067564
TukeyHSD(model3)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = distances ~ group, data = df)
## 
## $group
##                                     diff        lwr       upr     p adj
## square-Ephedra californica   -0.07814121 -0.4764919 0.3202095 0.8661054
## triangle-Ephedra californica -0.13728528 -0.5356360 0.2610654 0.6479043
## triangle-square              -0.05914407 -0.4894120 0.3711238 0.9314833
permutest(model3, pairwise = TRUE)
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df  Sum Sq  Mean Sq      F N.Perm Pr(>F)
## Groups     2 0.05652 0.028259 0.4183    999  0.659
## Residuals 14 0.94590 0.067564                     
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##                     Ephedra californica  square triangle
## Ephedra californica                     0.62100    0.373
## square                          0.61666            0.726
## triangle                        0.38332 0.73363
boxplot(model3, xlab = "Microsite")

### PCOA mojave 2022
pca_data_final_mojave2022 <-  microsite_obvs_mojave2022%>%
  spread(scientific_name, captures) %>%
  replace(is.na(.),0)%>% ungroup() %>% dplyr::select(-microsite) 

adonis(pca_data_final_mojave2022 ~ microsite, data = microsite_obvs_mojave2022)
## 'adonis' will be deprecated: use 'adonis2' instead
## $aov.tab
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs  MeanSqs F.Model      R2 Pr(>F)
## microsite  3   0.29696 0.098986 0.43984 0.15861  0.966
## Residuals  7   1.57534 0.225048         0.84139       
## Total     10   1.87229                  1.00000       
## 
## $call
## adonis(formula = pca_data_final_mojave2022 ~ microsite, data = microsite_obvs_mojave2022)
## 
## $coefficients
##              total Canis latrans Dipodomys heermanni Dipodomys ingens
## (Intercept)  6.875        1.0625              0.1875           0.0625
## microsite1  -1.125       -1.0625              0.0625          -0.0625
## microsite2   1.125        1.9375             -0.1875          -0.0625
## microsite3  -0.375       -1.0625              0.3125          -0.0625
##             Dipsosaurus dorsalis Lepus californicus Xerospermophilus mohavensis
## (Intercept)               0.1875             0.5625                       0.875
## microsite1                0.5625             0.6875                      -0.875
## microsite2               -0.1875            -0.5625                      -0.875
## microsite3               -0.1875            -0.5625                       0.625
## 
## $coef.sites
##                       1          2           3           4          5
## (Intercept)  0.61544053  0.3635299  0.42164537  0.42431662  0.4079359
## microsite1  -0.14812027  0.1210750 -0.03225940  0.08878293  0.1239501
## microsite2   0.03161829 -0.3635299 -0.08831204 -0.06431662 -0.3246025
## microsite3   0.01233725  0.1736130  0.12002130 -0.04196367  0.1707678
##                       6           7           8           9          10
## (Intercept)  0.58174444  0.38419524  0.75162546  0.58174444  0.40121366
## microsite1  -0.08095079 -0.03298954  0.01169872 -0.08095079 -0.04034409
## microsite2   0.13254127 -0.11146797  0.09452839  0.13254127 -0.09686583
## microsite3  -0.19939150  0.11294762 -0.01412546 -0.19939150  0.11929916
##                      11
## (Intercept)  0.50286620
## microsite1   0.09651797
## microsite2  -0.03619953
## microsite3  -0.01801771
## 
## $f.perms
##              [,1]
##    [1,] 1.4557543
##    [2,] 1.1507690
##    [3,] 1.1251731
##    [4,] 1.1869726
##    [5,] 0.6456375
##    [6,] 2.4452936
##    [7,] 0.6603086
##    [8,] 0.7163970
##    [9,] 1.0267207
##   [10,] 1.7961119
##   [11,] 0.6978174
##   [12,] 0.7689626
##   [13,] 0.8776466
##   [14,] 1.8413046
##   [15,] 1.4148311
##   [16,] 0.3856174
##   [17,] 0.5520107
##   [18,] 1.0320766
##   [19,] 0.4352292
##   [20,] 1.1259391
##   [21,] 1.4487245
##   [22,] 1.7634503
##   [23,] 1.3181841
##   [24,] 2.1225054
##   [25,] 1.0720690
##   [26,] 1.1297754
##   [27,] 2.6959305
##   [28,] 1.0021047
##   [29,] 1.1082860
##   [30,] 0.5139262
##   [31,] 1.3910860
##   [32,] 1.2458158
##   [33,] 1.1779923
##   [34,] 2.0117686
##   [35,] 1.0627403
##   [36,] 0.4477914
##   [37,] 0.6167657
##   [38,] 1.0538753
##   [39,] 1.7627918
##   [40,] 1.4929038
##   [41,] 0.4392645
##   [42,] 0.4419441
##   [43,] 1.7947268
##   [44,] 0.9802531
##   [45,] 1.9580587
##   [46,] 0.5422499
##   [47,] 0.7238218
##   [48,] 0.6251604
##   [49,] 0.9599506
##   [50,] 1.0890959
##   [51,] 0.8977738
##   [52,] 0.6517479
##   [53,] 0.5000277
##   [54,] 2.0586540
##   [55,] 0.6019733
##   [56,] 0.8939387
##   [57,] 0.6188341
##   [58,] 0.6097839
##   [59,] 1.1821997
##   [60,] 1.6116298
##   [61,] 1.9470301
##   [62,] 0.5985862
##   [63,] 0.8083587
##   [64,] 0.4160078
##   [65,] 0.3923106
##   [66,] 0.7011125
##   [67,] 1.0081121
##   [68,] 0.9792171
##   [69,] 0.5802778
##   [70,] 0.8161072
##   [71,] 0.8033641
##   [72,] 0.3880910
##   [73,] 0.5039963
##   [74,] 1.0722733
##   [75,] 1.4418813
##   [76,] 1.0217706
##   [77,] 0.9128302
##   [78,] 2.7743839
##   [79,] 0.9925403
##   [80,] 1.0056221
##   [81,] 0.7216168
##   [82,] 1.2184529
##   [83,] 0.5991929
##   [84,] 0.8267818
##   [85,] 0.9088564
##   [86,] 0.8242381
##   [87,] 1.9017712
##   [88,] 1.3560859
##   [89,] 0.9189775
##   [90,] 0.6017514
##   [91,] 0.5741843
##   [92,] 0.7462111
##   [93,] 3.7369094
##   [94,] 0.9148272
##   [95,] 1.1820690
##   [96,] 1.6134653
##   [97,] 1.2908535
##   [98,] 0.3938920
##   [99,] 0.3799215
##  [100,] 0.8650270
##  [101,] 0.7217141
##  [102,] 1.8691146
##  [103,] 1.2374450
##  [104,] 1.2056367
##  [105,] 1.2879408
##  [106,] 0.8794901
##  [107,] 0.4751718
##  [108,] 0.9400737
##  [109,] 1.0076553
##  [110,] 0.5754079
##  [111,] 1.6778001
##  [112,] 1.6087430
##  [113,] 0.3716049
##  [114,] 0.9431907
##  [115,] 1.8510725
##  [116,] 1.4427923
##  [117,] 1.2392908
##  [118,] 0.4971485
##  [119,] 0.6371984
##  [120,] 2.9948392
##  [121,] 0.6449920
##  [122,] 1.1219551
##  [123,] 0.8067584
##  [124,] 0.7707678
##  [125,] 0.5512480
##  [126,] 2.0764079
##  [127,] 0.3416967
##  [128,] 0.6129197
##  [129,] 1.2229790
##  [130,] 0.7468677
##  [131,] 0.8030276
##  [132,] 0.5749282
##  [133,] 0.4258266
##  [134,] 1.1865351
##  [135,] 1.7227026
##  [136,] 1.2005200
##  [137,] 0.6857437
##  [138,] 1.7892324
##  [139,] 0.7034600
##  [140,] 0.5595084
##  [141,] 1.5194473
##  [142,] 0.5157535
##  [143,] 0.4692241
##  [144,] 0.9557664
##  [145,] 0.8365479
##  [146,] 0.9510342
##  [147,] 1.2109811
##  [148,] 0.5236267
##  [149,] 0.5675355
##  [150,] 0.8827700
##  [151,] 2.0109618
##  [152,] 1.1499443
##  [153,] 0.9224585
##  [154,] 0.4587918
##  [155,] 1.3355776
##  [156,] 0.4902302
##  [157,] 0.5838084
##  [158,] 1.8891173
##  [159,] 1.0611417
##  [160,] 0.6155962
##  [161,] 1.8213434
##  [162,] 0.5695568
##  [163,] 0.6903056
##  [164,] 0.7721283
##  [165,] 0.4780732
##  [166,] 0.4881843
##  [167,] 1.6350720
##  [168,] 1.3625971
##  [169,] 0.5775343
##  [170,] 0.8816022
##  [171,] 1.0170230
##  [172,] 1.2913446
##  [173,] 0.6198291
##  [174,] 0.5650040
##  [175,] 1.2470691
##  [176,] 1.0280991
##  [177,] 1.1346671
##  [178,] 0.6976528
##  [179,] 1.5130980
##  [180,] 0.5228482
##  [181,] 0.6078489
##  [182,] 2.1089719
##  [183,] 2.1282312
##  [184,] 1.1307845
##  [185,] 0.5691924
##  [186,] 1.8689347
##  [187,] 0.7290320
##  [188,] 0.5780788
##  [189,] 0.8276405
##  [190,] 1.7647098
##  [191,] 1.1647292
##  [192,] 0.8476850
##  [193,] 1.4527052
##  [194,] 1.0195068
##  [195,] 2.4600375
##  [196,] 0.8963988
##  [197,] 0.5716511
##  [198,] 1.0185908
##  [199,] 0.9348778
##  [200,] 0.6413137
##  [201,] 0.6787884
##  [202,] 0.6405156
##  [203,] 1.1256806
##  [204,] 0.9029695
##  [205,] 0.7168524
##  [206,] 1.2262673
##  [207,] 1.2197768
##  [208,] 0.4877215
##  [209,] 0.9939874
##  [210,] 0.6433829
##  [211,] 1.1656934
##  [212,] 0.4237141
##  [213,] 1.0767347
##  [214,] 1.9823754
##  [215,] 1.1758231
##  [216,] 0.5162815
##  [217,] 0.9271359
##  [218,] 0.7103043
##  [219,] 1.3206510
##  [220,] 1.2553552
##  [221,] 0.4676795
##  [222,] 0.6161444
##  [223,] 3.1071742
##  [224,] 1.1494484
##  [225,] 0.5388758
##  [226,] 0.9585442
##  [227,] 1.1610988
##  [228,] 0.5398934
##  [229,] 1.8691146
##  [230,] 1.8025356
##  [231,] 0.6357329
##  [232,] 0.9353835
##  [233,] 0.8769554
##  [234,] 0.9364997
##  [235,] 1.2538858
##  [236,] 0.8959310
##  [237,] 1.0767347
##  [238,] 0.6369161
##  [239,] 0.6472790
##  [240,] 0.7813201
##  [241,] 0.8605537
##  [242,] 0.7385504
##  [243,] 1.1528771
##  [244,] 0.8208571
##  [245,] 0.7331260
##  [246,] 1.5872343
##  [247,] 1.3260979
##  [248,] 1.0549966
##  [249,] 1.3131835
##  [250,] 0.9820807
##  [251,] 0.7103515
##  [252,] 0.9489052
##  [253,] 0.5730595
##  [254,] 2.6493926
##  [255,] 1.7373591
##  [256,] 1.0093452
##  [257,] 0.4351915
##  [258,] 1.4310155
##  [259,] 0.6531743
##  [260,] 0.5175997
##  [261,] 1.0259335
##  [262,] 0.6811674
##  [263,] 1.7982926
##  [264,] 1.2409266
##  [265,] 1.3633596
##  [266,] 0.6048327
##  [267,] 1.1550930
##  [268,] 1.4536000
##  [269,] 1.1667567
##  [270,] 0.9856886
##  [271,] 0.7832837
##  [272,] 0.5739431
##  [273,] 0.7103043
##  [274,] 3.6059758
##  [275,] 2.7867311
##  [276,] 0.4175681
##  [277,] 0.8884000
##  [278,] 0.7909375
##  [279,] 1.1846557
##  [280,] 0.8687634
##  [281,] 1.0664517
##  [282,] 1.4591305
##  [283,] 0.8053277
##  [284,] 1.2378036
##  [285,] 1.3369568
##  [286,] 1.0590798
##  [287,] 0.5716511
##  [288,] 0.6783989
##  [289,] 0.8547246
##  [290,] 1.7251979
##  [291,] 1.0678040
##  [292,] 1.0519715
##  [293,] 0.9155763
##  [294,] 0.9041539
##  [295,] 0.8136897
##  [296,] 0.8973230
##  [297,] 0.9336942
##  [298,] 0.6346303
##  [299,] 2.4554615
##  [300,] 0.8100227
##  [301,] 1.7566700
##  [302,] 0.6358136
##  [303,] 0.8078828
##  [304,] 0.4014069
##  [305,] 1.0457613
##  [306,] 0.7907663
##  [307,] 0.9324873
##  [308,] 0.9140884
##  [309,] 0.5233023
##  [310,] 0.5393439
##  [311,] 1.1258697
##  [312,] 0.4561162
##  [313,] 0.4662395
##  [314,] 2.1749295
##  [315,] 0.7468677
##  [316,] 1.0349483
##  [317,] 0.7187409
##  [318,] 0.9969896
##  [319,] 0.9896370
##  [320,] 0.7094518
##  [321,] 0.5732338
##  [322,] 1.0806138
##  [323,] 0.4187862
##  [324,] 0.7435855
##  [325,] 0.6304476
##  [326,] 0.6073275
##  [327,] 1.4320827
##  [328,] 0.9050051
##  [329,] 0.7547680
##  [330,] 1.1995801
##  [331,] 0.4793581
##  [332,] 1.0703576
##  [333,] 0.5186395
##  [334,] 0.4797786
##  [335,] 1.2890700
##  [336,] 1.3412492
##  [337,] 0.7947235
##  [338,] 0.6624396
##  [339,] 0.6969514
##  [340,] 0.4508549
##  [341,] 1.2952343
##  [342,] 0.6472790
##  [343,] 0.9162204
##  [344,] 0.9623052
##  [345,] 0.7252339
##  [346,] 1.3560859
##  [347,] 1.8949489
##  [348,] 0.7360523
##  [349,] 0.5178995
##  [350,] 0.5857279
##  [351,] 0.4799987
##  [352,] 0.6294077
##  [353,] 1.1242093
##  [354,] 1.0305086
##  [355,] 0.5754554
##  [356,] 0.4897974
##  [357,] 1.0724699
##  [358,] 1.0527183
##  [359,] 0.5456354
##  [360,] 1.0330442
##  [361,] 2.2998648
##  [362,] 0.6695035
##  [363,] 1.4660838
##  [364,] 0.6670596
##  [365,] 1.3407872
##  [366,] 1.9689708
##  [367,] 0.8082740
##  [368,] 1.0348531
##  [369,] 0.9821756
##  [370,] 0.4842981
##  [371,] 1.4318498
##  [372,] 0.4004685
##  [373,] 1.3033187
##  [374,] 0.4976465
##  [375,] 0.9789400
##  [376,] 0.9103634
##  [377,] 1.0244388
##  [378,] 0.5161166
##  [379,] 0.5358942
##  [380,] 0.5984682
##  [381,] 2.0473322
##  [382,] 1.0311843
##  [383,] 0.7573100
##  [384,] 0.9350935
##  [385,] 1.2940642
##  [386,] 0.7010393
##  [387,] 0.8986426
##  [388,] 1.1295180
##  [389,] 1.1867963
##  [390,] 1.1588096
##  [391,] 0.4755123
##  [392,] 0.4853752
##  [393,] 0.5007198
##  [394,] 2.1573186
##  [395,] 4.0115029
##  [396,] 1.9318891
##  [397,] 0.6096779
##  [398,] 1.8204698
##  [399,] 0.7379415
##  [400,] 1.4327772
##  [401,] 0.9568016
##  [402,] 1.4004442
##  [403,] 0.8492596
##  [404,] 1.1275672
##  [405,] 0.6730117
##  [406,] 0.5465771
##  [407,] 0.7159083
##  [408,] 1.5245096
##  [409,] 0.7570444
##  [410,] 0.7149367
##  [411,] 1.2764463
##  [412,] 0.9922868
##  [413,] 1.8216434
##  [414,] 1.0304141
##  [415,] 1.4224707
##  [416,] 0.6978174
##  [417,] 1.3746598
##  [418,] 1.3019553
##  [419,] 0.6371648
##  [420,] 1.2921482
##  [421,] 0.6374865
##  [422,] 0.5667587
##  [423,] 3.1592873
##  [424,] 0.9377454
##  [425,] 0.7464691
##  [426,] 0.8990142
##  [427,] 0.8066378
##  [428,] 1.0522484
##  [429,] 0.9605452
##  [430,] 1.6142262
##  [431,] 0.4352292
##  [432,] 0.5057968
##  [433,] 2.7886239
##  [434,] 0.6603180
##  [435,] 0.4146018
##  [436,] 1.3567037
##  [437,] 1.3355776
##  [438,] 0.4223272
##  [439,] 0.7448889
##  [440,] 0.6115000
##  [441,] 1.4394626
##  [442,] 0.4665353
##  [443,] 0.9704242
##  [444,] 0.7090599
##  [445,] 2.3454359
##  [446,] 0.5797611
##  [447,] 0.8755146
##  [448,] 0.4921525
##  [449,] 0.7081943
##  [450,] 0.7960615
##  [451,] 1.9537151
##  [452,] 0.8776630
##  [453,] 0.8257788
##  [454,] 1.2531617
##  [455,] 0.5377018
##  [456,] 1.5856809
##  [457,] 1.2365735
##  [458,] 0.7518062
##  [459,] 1.1537171
##  [460,] 0.6722164
##  [461,] 1.8019257
##  [462,] 0.9489052
##  [463,] 0.6713875
##  [464,] 0.3905089
##  [465,] 0.6900428
##  [466,] 0.9054523
##  [467,] 1.1062389
##  [468,] 0.8873818
##  [469,] 0.7806138
##  [470,] 1.1568875
##  [471,] 1.2802458
##  [472,] 2.2044696
##  [473,] 0.5650040
##  [474,] 1.4160392
##  [475,] 0.4788093
##  [476,] 0.6073139
##  [477,] 0.8205963
##  [478,] 0.6412701
##  [479,] 0.4688557
##  [480,] 1.1097631
##  [481,] 0.5825441
##  [482,] 1.9206444
##  [483,] 1.2836318
##  [484,] 2.4189949
##  [485,] 0.5897442
##  [486,] 0.9612458
##  [487,] 2.8931590
##  [488,] 0.4876458
##  [489,] 0.5669290
##  [490,] 1.3945042
##  [491,] 2.3138595
##  [492,] 0.8551554
##  [493,] 0.5281999
##  [494,] 1.8227284
##  [495,] 0.5395313
##  [496,] 0.5565432
##  [497,] 2.1310403
##  [498,] 0.4664981
##  [499,] 0.5622803
##  [500,] 0.4014127
##  [501,] 1.4891939
##  [502,] 0.8751867
##  [503,] 0.5357901
##  [504,] 0.5497468
##  [505,] 1.7932702
##  [506,] 1.1141439
##  [507,] 0.5545966
##  [508,] 0.5143887
##  [509,] 2.2227707
##  [510,] 0.8441411
##  [511,] 0.9083157
##  [512,] 1.7870666
##  [513,] 0.4751718
##  [514,] 1.5386850
##  [515,] 1.0562299
##  [516,] 1.3266114
##  [517,] 2.7429542
##  [518,] 1.3051484
##  [519,] 2.2107213
##  [520,] 0.5752036
##  [521,] 1.2891951
##  [522,] 0.5449454
##  [523,] 0.5398371
##  [524,] 1.4244276
##  [525,] 0.6274630
##  [526,] 0.7638788
##  [527,] 2.2356972
##  [528,] 1.2995939
##  [529,] 0.9705555
##  [530,] 0.4322271
##  [531,] 1.4327772
##  [532,] 1.2814262
##  [533,] 1.5466654
##  [534,] 0.4575628
##  [535,] 0.5161166
##  [536,] 0.6837674
##  [537,] 1.6728860
##  [538,] 1.3090628
##  [539,] 0.7028951
##  [540,] 0.5611089
##  [541,] 0.5468924
##  [542,] 1.0204584
##  [543,] 1.1217531
##  [544,] 1.4808091
##  [545,] 0.5809002
##  [546,] 1.6519208
##  [547,] 0.5588979
##  [548,] 0.6544973
##  [549,] 0.5300240
##  [550,] 2.9959124
##  [551,] 1.5184860
##  [552,] 0.4876458
##  [553,] 0.9472619
##  [554,] 0.8739014
##  [555,] 0.9970953
##  [556,] 0.5672546
##  [557,] 0.5662681
##  [558,] 0.5068920
##  [559,] 1.8787905
##  [560,] 1.1131612
##  [561,] 1.3334337
##  [562,] 0.5468924
##  [563,] 2.1234044
##  [564,] 1.4382726
##  [565,] 2.1809101
##  [566,] 1.8813480
##  [567,] 0.7396347
##  [568,] 1.8500698
##  [569,] 0.5518513
##  [570,] 0.9620253
##  [571,] 0.6971934
##  [572,] 1.0467281
##  [573,] 1.0414015
##  [574,] 0.9728649
##  [575,] 0.5714373
##  [576,] 0.5084593
##  [577,] 1.0093452
##  [578,] 1.3717516
##  [579,] 1.0076134
##  [580,] 0.5490339
##  [581,] 2.9964077
##  [582,] 0.5826855
##  [583,] 1.2891104
##  [584,] 0.9062868
##  [585,] 0.9884379
##  [586,] 0.5058112
##  [587,] 0.7883141
##  [588,] 1.0010944
##  [589,] 1.4320461
##  [590,] 1.4738498
##  [591,] 2.2534606
##  [592,] 0.6134477
##  [593,] 1.1807624
##  [594,] 1.1307845
##  [595,] 0.5793714
##  [596,] 0.6186616
##  [597,] 1.0231275
##  [598,] 0.6152263
##  [599,] 0.9135680
##  [600,] 1.0340255
##  [601,] 1.3940252
##  [602,] 1.5145644
##  [603,] 0.8167871
##  [604,] 0.8514632
##  [605,] 1.6919089
##  [606,] 0.5299453
##  [607,] 1.2913730
##  [608,] 0.6938112
##  [609,] 0.9157108
##  [610,] 0.4140446
##  [611,] 3.2093809
##  [612,] 0.8242381
##  [613,] 1.1236451
##  [614,] 0.4361214
##  [615,] 1.1855964
##  [616,] 0.8496580
##  [617,] 0.9929925
##  [618,] 2.1127475
##  [619,] 0.4645106
##  [620,] 0.5962948
##  [621,] 0.5957822
##  [622,] 0.5691924
##  [623,] 0.9488178
##  [624,] 0.6218148
##  [625,] 1.7472933
##  [626,] 0.9592805
##  [627,] 0.7604856
##  [628,] 0.9135680
##  [629,] 0.7603024
##  [630,] 0.6239314
##  [631,] 0.4890822
##  [632,] 0.6060361
##  [633,] 0.7879065
##  [634,] 1.0186957
##  [635,] 2.0235390
##  [636,] 0.9715317
##  [637,] 0.5458877
##  [638,] 1.5679234
##  [639,] 1.2943985
##  [640,] 0.9108791
##  [641,] 3.0363588
##  [642,] 1.8422591
##  [643,] 0.5585876
##  [644,] 0.6116492
##  [645,] 1.3279243
##  [646,] 0.6167657
##  [647,] 0.6482801
##  [648,] 1.1625057
##  [649,] 0.6096363
##  [650,] 1.6063193
##  [651,] 0.4641317
##  [652,] 1.2121148
##  [653,] 0.5512480
##  [654,] 0.7487827
##  [655,] 0.6760666
##  [656,] 1.1707816
##  [657,] 0.7411126
##  [658,] 1.4861509
##  [659,] 1.6354998
##  [660,] 1.0953191
##  [661,] 0.5071477
##  [662,] 1.5644188
##  [663,] 2.3377358
##  [664,] 2.1531754
##  [665,] 0.8146589
##  [666,] 0.6477057
##  [667,] 0.6144665
##  [668,] 1.3794622
##  [669,] 0.6152973
##  [670,] 2.2147628
##  [671,] 0.9212970
##  [672,] 0.3882074
##  [673,] 3.2976104
##  [674,] 0.5981341
##  [675,] 2.6860394
##  [676,] 1.0251516
##  [677,] 2.0663994
##  [678,] 1.2990788
##  [679,] 1.8591501
##  [680,] 0.6687234
##  [681,] 0.6036971
##  [682,] 0.9900851
##  [683,] 0.8022430
##  [684,] 0.9862488
##  [685,] 1.0185908
##  [686,] 1.1874758
##  [687,] 2.0772233
##  [688,] 1.0371693
##  [689,] 0.8010658
##  [690,] 0.5055495
##  [691,] 0.7208543
##  [692,] 1.7640616
##  [693,] 0.6677158
##  [694,] 0.8613642
##  [695,] 0.3905089
##  [696,] 2.6131460
##  [697,] 0.7209601
##  [698,] 0.9807383
##  [699,] 0.6256364
##  [700,] 1.7227026
##  [701,] 0.5155316
##  [702,] 1.0201180
##  [703,] 0.8308487
##  [704,] 0.6679777
##  [705,] 0.5601362
##  [706,] 1.8019257
##  [707,] 1.6495309
##  [708,] 1.4879221
##  [709,] 1.1991685
##  [710,] 1.1051407
##  [711,] 0.7868286
##  [712,] 1.5307262
##  [713,] 0.4086242
##  [714,] 2.2793915
##  [715,] 1.4794700
##  [716,] 1.3560833
##  [717,] 1.0224382
##  [718,] 0.9359463
##  [719,] 1.3502347
##  [720,] 0.5549439
##  [721,] 0.9779230
##  [722,] 0.8423369
##  [723,] 1.0003839
##  [724,] 0.5637919
##  [725,] 0.5912083
##  [726,] 1.0941143
##  [727,] 1.3633596
##  [728,] 1.1346309
##  [729,] 0.6469734
##  [730,] 0.4309230
##  [731,] 0.5211167
##  [732,] 0.9701684
##  [733,] 0.4673255
##  [734,] 0.4971485
##  [735,] 0.6115000
##  [736,] 1.2337998
##  [737,] 0.9779230
##  [738,] 1.7716084
##  [739,] 1.0536232
##  [740,] 0.4751152
##  [741,] 0.7096630
##  [742,] 0.5198019
##  [743,] 0.4537489
##  [744,] 0.4449425
##  [745,] 1.0490280
##  [746,] 0.9415775
##  [747,] 0.7017276
##  [748,] 1.0351955
##  [749,] 1.3214909
##  [750,] 0.7787103
##  [751,] 1.6915182
##  [752,] 0.7935781
##  [753,] 0.6036971
##  [754,] 0.4768280
##  [755,] 1.1723654
##  [756,] 1.1824944
##  [757,] 0.5962345
##  [758,] 0.5081333
##  [759,] 0.8499368
##  [760,] 1.0602160
##  [761,] 1.4643340
##  [762,] 0.6469206
##  [763,] 0.9258818
##  [764,] 1.1937345
##  [765,] 0.9575026
##  [766,] 1.8591501
##  [767,] 0.9348887
##  [768,] 1.5607114
##  [769,] 1.2929354
##  [770,] 0.4667223
##  [771,] 0.5672414
##  [772,] 1.0351450
##  [773,] 2.2116298
##  [774,] 0.9168886
##  [775,] 1.0286147
##  [776,] 1.2942095
##  [777,] 1.3800210
##  [778,] 1.4417934
##  [779,] 0.9819520
##  [780,] 1.8653431
##  [781,] 0.5297234
##  [782,] 1.0924370
##  [783,] 0.7603024
##  [784,] 0.5923160
##  [785,] 0.8243742
##  [786,] 0.8856344
##  [787,] 0.5177164
##  [788,] 0.5473816
##  [789,] 1.8941413
##  [790,] 0.7810408
##  [791,] 1.3441825
##  [792,] 0.7698183
##  [793,] 0.8671068
##  [794,] 1.2588779
##  [795,] 1.8009988
##  [796,] 0.6300713
##  [797,] 0.5148480
##  [798,] 0.5737499
##  [799,] 0.9263142
##  [800,] 1.1052666
##  [801,] 0.4787148
##  [802,] 1.4625368
##  [803,] 0.4665353
##  [804,] 1.0826669
##  [805,] 0.6179867
##  [806,] 0.7117390
##  [807,] 1.3090628
##  [808,] 2.1504914
##  [809,] 0.8308487
##  [810,] 1.5491442
##  [811,] 1.0419770
##  [812,] 0.8816947
##  [813,] 0.9575026
##  [814,] 0.5283917
##  [815,] 1.0311843
##  [816,] 0.3894096
##  [817,] 0.6142566
##  [818,] 0.6285500
##  [819,] 1.0938559
##  [820,] 0.4064216
##  [821,] 3.6295687
##  [822,] 0.8618173
##  [823,] 1.4418813
##  [824,] 0.4933267
##  [825,] 0.3914258
##  [826,] 1.5392341
##  [827,] 1.6332184
##  [828,] 0.8441411
##  [829,] 0.9592046
##  [830,] 1.4440107
##  [831,] 0.8515292
##  [832,] 0.5761541
##  [833,] 0.9948507
##  [834,] 0.7053801
##  [835,] 0.7440158
##  [836,] 0.5475135
##  [837,] 1.3979515
##  [838,] 0.9319808
##  [839,] 1.1242093
##  [840,] 1.0101254
##  [841,] 1.0992682
##  [842,] 1.6415215
##  [843,] 1.1697836
##  [844,] 2.3028974
##  [845,] 1.1250500
##  [846,] 0.5840055
##  [847,] 0.8329768
##  [848,] 1.3942645
##  [849,] 0.6285483
##  [850,] 0.4449425
##  [851,] 0.5666670
##  [852,] 1.1059861
##  [853,] 0.5732650
##  [854,] 2.0398706
##  [855,] 1.3026465
##  [856,] 1.8214630
##  [857,] 0.6705238
##  [858,] 2.6263615
##  [859,] 3.6094324
##  [860,] 0.5611089
##  [861,] 1.1027492
##  [862,] 1.4132015
##  [863,] 0.6132844
##  [864,] 1.2382896
##  [865,] 0.9599506
##  [866,] 0.4478218
##  [867,] 1.3242815
##  [868,] 0.8445457
##  [869,] 1.2943985
##  [870,] 1.0301664
##  [871,] 0.8297451
##  [872,] 0.4678895
##  [873,] 1.9634385
##  [874,] 1.3436813
##  [875,] 0.6312510
##  [876,] 0.8053277
##  [877,] 1.2740039
##  [878,] 0.8636621
##  [879,] 0.7963857
##  [880,] 0.5783271
##  [881,] 2.2022310
##  [882,] 0.7024189
##  [883,] 0.4503817
##  [884,] 1.1293420
##  [885,] 0.9043796
##  [886,] 0.9228995
##  [887,] 1.9017712
##  [888,] 0.9401167
##  [889,] 2.2270574
##  [890,] 0.7395269
##  [891,] 0.9162951
##  [892,] 1.3127020
##  [893,] 0.7008105
##  [894,] 0.4224886
##  [895,] 0.7519597
##  [896,] 1.1511277
##  [897,] 2.0364382
##  [898,] 0.3784470
##  [899,] 2.0347788
##  [900,] 0.6510017
##  [901,] 1.4403477
##  [902,] 0.6530710
##  [903,] 1.3884505
##  [904,] 0.5999773
##  [905,] 0.7331310
##  [906,] 0.7675224
##  [907,] 0.8827700
##  [908,] 0.7640291
##  [909,] 0.7011766
##  [910,] 0.6769229
##  [911,] 1.0414015
##  [912,] 1.2519537
##  [913,] 0.9389076
##  [914,] 1.2102331
##  [915,] 0.5716727
##  [916,] 0.7751154
##  [917,] 0.4784330
##  [918,] 1.0443847
##  [919,] 1.6564711
##  [920,] 0.5610592
##  [921,] 0.9315854
##  [922,] 0.6025139
##  [923,] 1.1610988
##  [924,] 1.3090628
##  [925,] 1.2519537
##  [926,] 0.7962775
##  [927,] 0.5763634
##  [928,] 1.0873868
##  [929,] 0.9020392
##  [930,] 0.5281441
##  [931,] 0.7034600
##  [932,] 1.1622531
##  [933,] 0.6856125
##  [934,] 3.3918648
##  [935,] 0.9519589
##  [936,] 1.1079980
##  [937,] 1.5752722
##  [938,] 0.9189813
##  [939,] 0.9359463
##  [940,] 0.6076093
##  [941,] 2.4118171
##  [942,] 1.5069291
##  [943,] 0.6628427
##  [944,] 0.7083188
##  [945,] 1.1401569
##  [946,] 1.0384334
##  [947,] 0.7297349
##  [948,] 0.6931509
##  [949,] 0.7533514
##  [950,] 0.9128302
##  [951,] 0.9969548
##  [952,] 2.7213493
##  [953,] 0.9071029
##  [954,] 1.2313625
##  [955,] 0.9198353
##  [956,] 0.5912835
##  [957,] 0.7360906
##  [958,] 1.4407631
##  [959,] 0.9254243
##  [960,] 0.9633722
##  [961,] 1.3854207
##  [962,] 0.7017276
##  [963,] 0.5591768
##  [964,] 0.6459604
##  [965,] 0.6259468
##  [966,] 0.6289635
##  [967,] 1.3720777
##  [968,] 0.6824417
##  [969,] 0.9281690
##  [970,] 0.8626836
##  [971,] 0.6949957
##  [972,] 0.8526568
##  [973,] 0.4477914
##  [974,] 0.5078317
##  [975,] 0.6689640
##  [976,] 1.4740143
##  [977,] 0.6603180
##  [978,] 1.3984599
##  [979,] 5.4136160
##  [980,] 1.9642518
##  [981,] 1.2470691
##  [982,] 0.6965158
##  [983,] 0.8184531
##  [984,] 0.8680996
##  [985,] 4.5652299
##  [986,] 0.9936159
##  [987,] 0.4888627
##  [988,] 0.6741451
##  [989,] 1.0252034
##  [990,] 0.8084566
##  [991,] 0.5665792
##  [992,] 1.0332217
##  [993,] 1.0913569
##  [994,] 0.7890015
##  [995,] 0.9004815
##  [996,] 2.2217508
##  [997,] 1.6581510
##  [998,] 1.0808812
##  [999,] 1.3720777
## 
## $model.matrix
##    (Intercept) microsite1 microsite2 microsite3
## 1            1          1          0          0
## 2            1          0          1          0
## 3            1         -1         -1         -1
## 4            1          0          0          1
## 5            1         -1         -1         -1
## 6            1          1          0          0
## 7            1          1          0          0
## 8            1         -1         -1         -1
## 9            1          0          0          1
## 10           1          1          0          0
## 11           1         -1         -1         -1
## 
## $terms
## pca_data_final_mojave2022 ~ microsite
## attr(,"variables")
## list(pca_data_final_mojave2022, microsite)
## attr(,"factors")
##                           microsite
## pca_data_final_mojave2022         0
## microsite                         1
## attr(,"term.labels")
## [1] "microsite"
## attr(,"order")
## [1] 1
## attr(,"intercept")
## [1] 1
## attr(,"response")
## [1] 1
## attr(,".Environment")
## <environment: R_GlobalEnv>
## 
## attr(,"class")
## [1] "adonis"
dist_final_mojave2022<-vegdist(pca_data_final_mojave2022, species = "bray")
res_final_mojave2022<-pcoa(dist_final_mojave2022)

p02_mojave2022 <- as.data.frame(res_final_mojave2022$vectors)%>%
  dplyr::select(Axis.1, Axis.2) %>% bind_cols(microsite_obvs_mojave2022)

ggplot() + 
  geom_point(data = p02_mojave2022, aes(x = Axis.1, y = Axis.2, color = microsite))+ theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ labs(color = "Microsite")+ ggtitle('Mojave 2022')

model4<-betadisper(dist_final_mojave2022, microsite_obvs_mojave2022$microsite)

anova(model4)
## Analysis of Variance Table
## 
## Response: Distances
##           Df  Sum Sq  Mean Sq F value Pr(>F)
## Groups     3 0.12926 0.043086  0.5455 0.6667
## Residuals  7 0.55292 0.078988
TukeyHSD(model4)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = distances ~ group, data = df)
## 
## $group
##                                    diff        lwr       upr     p adj
## open-Larrea tridentata     -0.348935979 -1.3890607 0.6911887 0.6950734
## square-Larrea tridentata    0.033416962 -0.7722602 0.8390941 0.9989851
## triangle-Larrea tridentata  0.040545421 -0.6172872 0.6983781 0.9967097
## square-open                 0.382352941 -0.7570466 1.5217525 0.6948943
## triangle-open               0.389481401 -0.6506433 1.4296061 0.6240468
## triangle-square             0.007128459 -0.7985487 0.8128056 0.9999901
permutest(model4, pairwise = TRUE)
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df  Sum Sq  Mean Sq      F N.Perm Pr(>F)
## Groups     3 0.12926 0.043086 0.5455    999   0.68
## Residuals  7 0.55292 0.078988                     
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##                   Larrea tridentata open  square triangle
## Larrea tridentata                        0.89700    0.846
## open                                                     
## square                      0.90506                 0.966
## triangle                    0.85641      0.97120
boxplot(model4, xlab = "Microsite")

### PCOA mojave 2023
pca_data_final_mojave2023 <-  microsite_obvs_mojave2023%>%
  spread(scientific_name, captures) %>%
  replace(is.na(.),0)%>% ungroup() %>% dplyr::select(-microsite) 

dist_final_mojave2023<-vegdist(pca_data_final_mojave2023, species = "bray")
res_final_mojave2023<-pcoa(dist_final_mojave2023)


###make the rows equal manually

microsite_obvs_mojave2023_new <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/microsite_obvs_mojave2023_new.csv")

p02_mojave2023 <- as.data.frame(res_final_mojave2023$vectors)%>%
  dplyr::select(Axis.1, Axis.2) %>% bind_cols(microsite_obvs_mojave2023_new)

ggplot() + 
  geom_point(data = p02_mojave2023, aes(x = Axis.1, y = Axis.2, color = microsite))+ theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ labs(color = "Microsite")+ ggtitle('Mojave 2023')

model5<-betadisper(dist_final_mojave2023, microsite_obvs_mojave2023_new$microsite)
## Warning in betadisper(dist_final_mojave2023,
## microsite_obvs_mojave2023_new$microsite): some squared distances are negative
## and changed to zero
anova(model5)
## Analysis of Variance Table
## 
## Response: Distances
##           Df Sum Sq  Mean Sq F value Pr(>F)
## Groups     3 0.2221 0.074035  0.7226  0.554
## Residuals 15 1.5368 0.102450
TukeyHSD(model5)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = distances ~ group, data = df)
## 
## $group
##                                   diff        lwr       upr     p adj
## open-Larrea tridentata     -0.33237257 -0.9846880 0.3199428 0.4792273
## square-Larrea tridentata   -0.10369488 -0.6991746 0.4917849 0.9573764
## triangle-Larrea tridentata -0.09283653 -0.6254498 0.4397768 0.9572625
## square-open                 0.22867770 -0.4759035 0.9332589 0.7866207
## triangle-open               0.23953604 -0.4127794 0.8918514 0.7189084
## triangle-square             0.01085834 -0.5846214 0.6063381 0.9999454
permutest(model5, pairwise = TRUE)
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df Sum Sq  Mean Sq      F N.Perm Pr(>F)
## Groups     3 0.2221 0.074035 0.7226    999  0.556
## Residuals 15 1.5368 0.102450                     
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##                   Larrea tridentata     open   square triangle
## Larrea tridentata                   0.030000 0.602000    0.564
## open                       0.016972          0.452000    0.343
## square                     0.619587 0.461186             0.954
## triangle                   0.589579 0.338820 0.968655
boxplot(model5, xlab = "Microsite")

### PCOA mojave winter 2023

pca_data_final_mojave2023_winter <-  microsite_obvs_mojave2023_winter%>%
  spread(scientific_name, captures) %>%
  replace(is.na(.),0)%>% ungroup() %>% dplyr::select(-microsite) 

dist_final_mojave2023_winter<-vegdist(pca_data_final_mojave2023_winter, species = "bray")
res_final_mojave2023_winter<-pcoa(dist_final_mojave2023_winter)

p02_mojave2023_winter <- as.data.frame(res_final_mojave2023_winter$vectors)%>%
  dplyr::select(Axis.1, Axis.2) %>% bind_cols(microsite_obvs_mojave2023_winter)

ggplot() + 
  geom_point(data = p02_mojave2023_winter, aes(x = Axis.1, y = Axis.2, color = microsite))+ theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ labs(color = "Microsite")+ ggtitle('Mojave Winter 2023')

model6<-betadisper(dist_final_mojave2023_winter, microsite_obvs_mojave2023_winter$microsite)

anova(model6)
## Warning in anova.lm(lm(Distances ~ Groups, data = model.dat)): ANOVA F-tests on
## an essentially perfect fit are unreliable
## Analysis of Variance Table
## 
## Response: Distances
##           Df     Sum Sq    Mean Sq    F value    Pr(>F)    
## Groups     1 0.00074074 0.00074074 1.3954e+29 1.704e-15 ***
## Residuals  1 0.00000000 0.00000000                         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(model6)
## Warning in qtukey(conf.level, length(means), x$df.residual): NaNs produced
## Warning in ptukey(abs(est), length(means), x$df.residual, lower.tail = FALSE):
## NaNs produced
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = distances ~ group, data = df)
## 
## $group
##                                diff lwr upr p adj
## square-Larrea tridentata 0.03333333 NaN NaN   NaN
permutest(model6, pairwise = TRUE)
## Warning in anova.lm(lm(Distances ~ Groups, data = model.dat)): ANOVA F-tests on
## an essentially perfect fit are unreliable
## 'nperm' >= set of all permutations: complete enumeration.
## Set of permutations < 'minperm'. Generating entire set.
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 5
## 
## Response: Distances
##           Df     Sum Sq    Mean Sq          F N.Perm Pr(>F)
## Groups     1 0.00074074 0.00074074 1.3954e+29      5 0.1667
## Residuals  1 0.00000000 0.00000000                         
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##                   Larrea tridentata square
## Larrea tridentata                         
## square
boxplot(model5, xlab = "Microsite")

### Calculate abundance and richness for each site and year
library(stringr)
richness_carrizo_2022<-microsite_obvs_carrizo2022 %>% group_by(microsite)%>% summarise(animals = sum(captures), richness = n())

richness_carrizo_2023<-microsite_obvs_carrizo2023 %>% group_by(microsite)%>% summarise(animals = sum(captures), richness = n())

richness_mojave2022<-microsite_obvs_mojave2022 %>% group_by(microsite)%>% summarise(animals = sum(captures), richness = n())

richness_mojave2023<-microsite_obvs_mojave2023 %>% group_by(microsite)%>% summarise(animals = sum(captures), richness = n()) 

richness_carrizo2023_winter<-microsite_obvs_carrizo2023_winter%>%  group_by(microsite)%>%summarise(animals = sum(captures), richness = n())

richness_mojave2023_winter<-microsite_obvs_mojave2023_winter%>% group_by(microsite)%>%summarise(animals = sum(captures), richness = n())

### Calculate abundance and richness for each site and year
evenness_carrizo2022 <- microsite_obvs_carrizo2022 %>%
  group_by(microsite) %>%
  summarize(evenness = diversity(captures, index = "shannon"))

evenness_carrizo2023 <- microsite_obvs_carrizo2023 %>%
  group_by(microsite) %>%
  summarize(evenness = diversity(captures, index = "shannon"))

evenness_mojave2022 <- microsite_obvs_mojave2022 %>%
  group_by(microsite) %>%
  summarize(evenness = diversity(captures, index = "shannon"))

evenness_mojave2023 <- microsite_obvs_mojave2023 %>%
  group_by(microsite) %>%
  summarize(evenness = diversity(captures, index = "shannon"))

evenness_carrizo2023_winter <- microsite_obvs_carrizo2023_winter %>%
  group_by(microsite) %>%
  summarize(evenness = diversity(captures, index = "shannon"))

evenness_mojave2023_winter <- microsite_obvs_mojave2023_winter%>%
  group_by(microsite) %>%
  summarize(evenness = diversity(captures, index = "shannon"))

data <-merge(evenness_mojave2023_winter, microsite_obvs_mojave2023_winter, by = "microsite")

data_1<-merge(data, richness_mojave2023_winter, by = "microsite")
###join richness, abundance, and evenness data to temperature data

library(emmeans)
temp_mojave2023_winter <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/Mojave_winter.csv")

temp_mojave2023_winter_final <- inner_join(temp_mojave2023_winter, richness_mojave2023_winter, by = "microsite")

temp_mojave2023_winter_final <- inner_join(temp_mojave2023_winter_final, evenness_mojave2023_winter, by = "microsite")

A1<-ggplot(temp_mojave2023_winter_final, aes(x=richness, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+xlab("Richness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)
## Warning: The `fun.y` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0.
## ℹ Please use the `fun` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `show_guide` argument of `layer()` is deprecated as of ggplot2 2.0.0.
## ℹ Please use the `show.legend` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
glm_1.1<-glm(formula = richness ~ temp*as.factor(microsite), data = temp_mojave2023_winter_final)
anova(glm_1.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                       1042     229.17             
## temp                       1     0.00      1041     229.17   <2e-16 ***
## as.factor(microsite)       1   229.17      1040       0.00   <2e-16 ***
## temp:as.factor(microsite)  1     0.00      1039       0.00        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_1.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE   df lower.CL upper.CL
##  Larrea tridentata      1 1.04e-15 1039        1        1
##  square                 2 7.22e-16 1039        2        2
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                   estimate       SE   df              t.ratio p.value
##  Larrea tridentata - square       -1 1.26e-15 1039 -790790212082967.000  <.0001
B1<-ggplot(temp_mojave2023_winter_final, aes(x=animals, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+xlab("Abundance") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_1.2<-glm(formula = animals ~ temp*as.factor(microsite), data = temp_mojave2023_winter_final)
anova(glm_1.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df   Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                         1042 0.0000e+00              
## temp                       1 0.0000e+00      1041 2.3977e-24 1.0000000    
## as.factor(microsite)       1 2.8229e-26      1040 2.3694e-24 0.0004882 ***
## temp:as.factor(microsite)  1 0.0000e+00      1039 2.4119e-24 1.0000000    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_1.2, pairwise ~ as.factor(microsite)) 
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE   df lower.CL upper.CL
##  Larrea tridentata      3 2.61e-15 1039        3        3
##  square                 3 1.82e-15 1039        3        3
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                    estimate       SE   df t.ratio p.value
##  Larrea tridentata - square -4.39e-15 3.18e-15 1039  -1.379  0.1683
C1<-ggplot(temp_mojave2023_winter_final, aes(x=evenness, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+xlab("Evenness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_1.3<-glm(formula = evenness ~ temp*as.factor(microsite), data = temp_mojave2023_winter_final)
anova(glm_1.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                       1042     92.847             
## temp                       1    0.000      1041     92.847   <2e-16 ***
## as.factor(microsite)       1   92.847      1040      0.000   <2e-16 ***
## temp:as.factor(microsite)  1    0.000      1039      0.000        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_1.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE   df lower.CL upper.CL
##  Larrea tridentata  0.000 6.00e-16 1039    0.000    0.000
##  square             0.637 4.17e-16 1039    0.637    0.637
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                   estimate       SE   df              t.ratio p.value
##  Larrea tridentata - square   -0.637 7.31e-16 1039 -871241605796212.000  <.0001
A1/B1/C1

temp_carrizo2023_winter <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/Carrizo_winter.csv")

temp_carrizo2023_winter_final <- inner_join(temp_carrizo2023_winter, richness_carrizo2023_winter, by = "microsite")

temp_carrizo2023_winter_final <- inner_join(temp_carrizo2023_winter_final, evenness_carrizo2023_winter, by = "microsite")

A2<-ggplot(temp_carrizo2023_winter_final, aes(x=richness, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+ xlab("Richness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_2.1<-glm(formula = richness ~ temp*as.factor(microsite), data = temp_carrizo2023_winter_final)
anova(glm_2.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                       2019     1766.8             
## temp                       1     2.52      2018     1764.3   <2e-16 ***
## as.factor(microsite)       2  1764.26      2016        0.0   <2e-16 ***
## temp:as.factor(microsite)  2     0.00      2014        0.0   0.8939    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_2.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE   df lower.CL upper.CL
##  Ephedra californica      8 7.51e-16 2014        8        8
##  square                   5 3.88e-16 2014        5        5
##  triangle                 6 3.88e-16 2014        6        6
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE   df               t.ratio
##  Ephedra californica - square          3 8.45e-16 2014  3548435964121619.000
##  Ephedra californica - triangle        2 8.45e-16 2014  2365476818958502.000
##  square - triangle                    -1 5.48e-16 2014 -1824387996209491.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
B2<-ggplot(temp_carrizo2023_winter_final, aes(x=animals, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+ xlab("Abundance") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_2.2<-glm(formula = animals ~ temp*as.factor(microsite), data = temp_carrizo2023_winter_final)
anova(glm_2.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                       2019    1563902             
## temp                       1     3266      2018    1560635   <2e-16 ***
## as.factor(microsite)       2  1560635      2016          0   <2e-16 ***
## temp:as.factor(microsite)  2        0      2014          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_2.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE   df lower.CL upper.CL
##  Ephedra californica    103 1.91e-14 2014      103      103
##  square                  13 9.85e-15 2014       13       13
##  triangle                24 9.85e-15 2014       24       24
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE   df              t.ratio
##  Ephedra californica - square         90 2.15e-14 2014 4189747062723428.000
##  Ephedra californica - triangle       79 2.15e-14 2014 3677438091485935.000
##  square - triangle                   -11 1.39e-14 2014 -789840628212904.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
C2<-ggplot(temp_carrizo2023_winter_final, aes(x=evenness, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+ xlab("Evenness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_2.3<-glm(formula = evenness ~ temp*as.factor(microsite), data = temp_carrizo2023_winter_final)
anova(glm_2.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                       2019   0.061377              
## temp                       1 0.000135      2018   0.061242 < 2.2e-16 ***
## as.factor(microsite)       2 0.061242      2016   0.000000 < 2.2e-16 ***
## temp:as.factor(microsite)  2 0.000000      2014   0.000000       NaN    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_2.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean SE   df lower.CL upper.CL
##  Ephedra californica   1.34  0 2014     1.34     1.34
##  square                1.33  0 2014     1.33     1.33
##  triangle              1.33  0 2014     1.33     1.33
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate SE   df t.ratio p.value
##  Ephedra californica - square    0.01754  0 2014     Inf  <.0001
##  Ephedra californica - triangle  0.01635  0 2014     Inf  <.0001
##  square - triangle              -0.00119  0 2014    -Inf  <.0001
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
A2/B2/C2

temp_carrizo2023 <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/Carrizo_2023.csv")

temp_carrizo2023_final <- inner_join(temp_carrizo2023, richness_carrizo_2023, by = "microsite")

temp_carrizo2023_final <- inner_join(temp_carrizo2023_final, evenness_carrizo2023, by = "microsite")


A3<-ggplot(temp_carrizo2023_final, aes(x=richness, y=temp, fill = microsite)) + 
  geom_boxplot()+ xlab("Richness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_3.1<-glm(formula = richness ~ temp*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_3.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      28584     117523             
## temp                       1       68     28583     117455   <2e-16 ***
## as.factor(microsite)       3   117455     28580          0   <2e-16 ***
## temp:as.factor(microsite)  3        0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_3.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica      4 3.61e-14 28577        4        4
##  open                     6 3.62e-14 28577        6        6
##  square                   7 2.39e-14 28577        7        7
##  triangle                10 2.88e-14 28577       10       10
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open           -2 5.11e-14 28577  -39116221894656.000
##  Ephedra californica - square         -3 4.33e-14 28577  -69212371737248.000
##  Ephedra californica - triangle       -6 4.62e-14 28577 -129781738905984.000
##  open - square                        -1 4.34e-14 28577  -23056040512286.000
##  open - triangle                      -4 4.63e-14 28577  -86472529307324.000
##  square - triangle                    -3 3.75e-14 28577  -80055956630215.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
B3<-ggplot(temp_carrizo2023_final, aes(x=animals, y=temp, fill = microsite)) + 
  geom_boxplot()+ xlab("Abundance") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_3.2<-glm(formula = animals ~ temp*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_3.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df  Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                       28584  223625068             
## temp                       1    282018     28583  223343051   <2e-16 ***
## as.factor(microsite)       3 223343051     28580          0   <2e-16 ***
## temp:as.factor(microsite)  3         0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_3.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica     36 8.83e-13 28577       36       36
##  open                    35 8.84e-13 28577       35       35
##  square                 228 5.85e-13 28577      228      228
##  triangle               212 7.05e-13 28577      212      212
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open            1 1.25e-12 28577     800213721293.000
##  Ephedra californica - square       -192 1.06e-12 28577 -181235301332426.000
##  Ephedra californica - triangle     -176 1.13e-12 28577 -155759338759681.000
##  open - square                      -193 1.06e-12 28577 -182062760819628.000
##  open - triangle                    -177 1.13e-12 28577 -156556291703959.000
##  square - triangle                    16 9.16e-13 28577   17469137693105.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
C3<-ggplot(temp_carrizo2023_final, aes(x=evenness, y=temp, fill = microsite)) + 
  geom_boxplot()+ xlab("Evenness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_3.3<-glm(formula = evenness ~ temp*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_3.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      28584     246.36             
## temp                       1    0.001     28583     246.36   <2e-16 ***
## as.factor(microsite)       3  246.361     28580       0.00   <2e-16 ***
## temp:as.factor(microsite)  3    0.000     28577       0.00        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_3.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica   1.35 1.30e-15 28577     1.35     1.35
##  open                  1.34 1.30e-15 28577     1.34     1.34
##  square                1.26 8.58e-16 28577     1.26     1.26
##  triangle              1.49 1.03e-15 28577     1.49     1.49
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open       0.0187 1.83e-15 28577   10186437074429.000
##  Ephedra californica - square     0.0992 1.55e-15 28577   63814239521076.000
##  Ephedra californica - triangle  -0.1332 1.66e-15 28577  -80380881588710.000
##  open - square                    0.0805 1.55e-15 28577   51765179306969.000
##  open - triangle                 -0.1519 1.66e-15 28577  -91595059372065.000
##  square - triangle               -0.2324 1.34e-15 28577 -172978098917653.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
A3/B3/C3
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).

temp_carrizo2022 <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/Carrizo_2022.csv")

temp_carrizo2022_final <- inner_join(temp_carrizo2022, richness_carrizo_2022, by = "microsite")


temp_carrizo2022_final <- inner_join(temp_carrizo2022_final, evenness_carrizo2022, by = "microsite")

A4<-ggplot(temp_carrizo2022_final, aes(x=richness, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Richness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_4.1<-glm(formula = richness ~ temp*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_4.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      28584     117523             
## temp                       1       68     28583     117455   <2e-16 ***
## as.factor(microsite)       3   117455     28580          0   <2e-16 ***
## temp:as.factor(microsite)  3        0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_4.1,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica      4 3.61e-14 28577        4        4
##  open                     6 3.62e-14 28577        6        6
##  square                   7 2.39e-14 28577        7        7
##  triangle                10 2.88e-14 28577       10       10
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open           -2 5.11e-14 28577  -39116221894656.000
##  Ephedra californica - square         -3 4.33e-14 28577  -69212371737248.000
##  Ephedra californica - triangle       -6 4.62e-14 28577 -129781738905984.000
##  open - square                        -1 4.34e-14 28577  -23056040512286.000
##  open - triangle                      -4 4.63e-14 28577  -86472529307324.000
##  square - triangle                    -3 3.75e-14 28577  -80055956630215.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
B4<-ggplot(temp_carrizo2022_final, aes(x=animals, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Abundance") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_4.2<-glm(formula = animals ~ temp*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_4.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df  Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                       28584  223625068             
## temp                       1    282018     28583  223343051   <2e-16 ***
## as.factor(microsite)       3 223343051     28580          0   <2e-16 ***
## temp:as.factor(microsite)  3         0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_4.2,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica     36 8.83e-13 28577       36       36
##  open                    35 8.84e-13 28577       35       35
##  square                 228 5.85e-13 28577      228      228
##  triangle               212 7.05e-13 28577      212      212
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open            1 1.25e-12 28577     800213721293.000
##  Ephedra californica - square       -192 1.06e-12 28577 -181235301332426.000
##  Ephedra californica - triangle     -176 1.13e-12 28577 -155759338759681.000
##  open - square                      -193 1.06e-12 28577 -182062760819628.000
##  open - triangle                    -177 1.13e-12 28577 -156556291703959.000
##  square - triangle                    16 9.16e-13 28577   17469137693105.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
C4<-ggplot(temp_carrizo2022_final, aes(x=evenness, y=temp, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Evenness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_4.3<-glm(formula = evenness ~ temp*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_4.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      28584     246.36             
## temp                       1    0.001     28583     246.36   <2e-16 ***
## as.factor(microsite)       3  246.361     28580       0.00   <2e-16 ***
## temp:as.factor(microsite)  3    0.000     28577       0.00        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_4.3,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica   1.35 1.30e-15 28577     1.35     1.35
##  open                  1.34 1.30e-15 28577     1.34     1.34
##  square                1.26 8.58e-16 28577     1.26     1.26
##  triangle              1.49 1.03e-15 28577     1.49     1.49
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open       0.0187 1.83e-15 28577   10186437074429.000
##  Ephedra californica - square     0.0992 1.55e-15 28577   63814239521076.000
##  Ephedra californica - triangle  -0.1332 1.66e-15 28577  -80380881588710.000
##  open - square                    0.0805 1.55e-15 28577   51765179306969.000
##  open - triangle                 -0.1519 1.66e-15 28577  -91595059372065.000
##  square - triangle               -0.2324 1.34e-15 28577 -172978098917653.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
A4/B4/C4
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).

temp_mojave2023 <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/Mojave_2023.csv")

temp_mojave2023_final <- inner_join(temp_mojave2023, richness_mojave2023, by = "microsite")

temp_mojave2023_final <- inner_join(temp_mojave2023_final, evenness_mojave2023, by = "microsite")

A5<-ggplot(temp_mojave2023_final, aes(x=richness, y=temp, fill = microsite)) + geom_boxplot()+ xlab("Richness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)


glm_5.1<-glm(formula = richness ~ temp*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_5.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      26676      12027             
## temp                       1    604.3     26675      11422   <2e-16 ***
## as.factor(microsite)       3  11422.4     26672          0   <2e-16 ***
## temp:as.factor(microsite)  3      0.0     26669          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_5.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata      6 9.73e-15 26669        6        6
##  open                   5 1.04e-14 26669        5        5
##  square                 4 1.90e-14 26669        4        4
##  triangle               6 1.04e-14 26669        6        6
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df             t.ratio
##  Larrea tridentata - open            1 1.43e-14 26669  70066546269864.000
##  Larrea tridentata - square          2 2.14e-14 26669  93592911720361.000
##  Larrea tridentata - triangle        0 1.42e-14 26669               1.000
##  open - square                       1 2.17e-14 26669  46072540267475.000
##  open - triangle                    -1 1.47e-14 26669 -67842498871048.000
##  square - triangle                  -2 2.17e-14 26669 -92232101206075.000
##  p.value
##   <.0001
##   <.0001
##   0.6182
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
B5<-ggplot(temp_mojave2023_final, aes(x=animals, y=temp, fill = microsite)) + geom_boxplot()+ xlab("Abundance") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_5.2<-glm(formula = animals ~ temp*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_5.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      26676   16686006             
## temp                       1    97871     26675   16588135   <2e-16 ***
## as.factor(microsite)       3 16588135     26672          0   <2e-16 ***
## temp:as.factor(microsite)  3        0     26669          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_5.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata     53 2.32e-13 26669       53       53
##  open                  32 2.49e-13 26669       32       32
##  square                76 4.55e-13 26669       76       76
##  triangle              96 2.48e-13 26669       96       96
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open           21 3.41e-13 26669   61594819226064.000
##  Larrea tridentata - square        -23 5.10e-13 26669  -45056243317339.000
##  Larrea tridentata - triangle      -43 3.40e-13 26669 -126398712668319.000
##  open - square                     -44 5.18e-13 26669  -84861169821908.000
##  open - triangle                   -64 3.52e-13 26669 -181759027178838.000
##  square - triangle                 -20 5.18e-13 26669  -38609687117316.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
C5<-ggplot(temp_mojave2023_final, aes(evenness, y=temp, fill = microsite)) + geom_boxplot()+ xlab("Evenness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") +stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_5.3<-glm(formula = evenness ~ temp*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_5.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                      26676     2804.8              
## temp                       1     34.0     26675     2770.8 < 2.2e-16 ***
## as.factor(microsite)       3   2770.8     26672        0.0 < 2.2e-16 ***
## temp:as.factor(microsite)  3      0.0     26669        0.0 1.771e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_5.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata  0.741 1.77e-15 26669    0.741    0.741
##  open               1.470 1.90e-15 26669    1.470    1.470
##  square             0.550 3.46e-15 26669    0.550    0.550
##  triangle           0.990 1.89e-15 26669    0.990    0.990
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open       -0.730 2.60e-15 26669 -281010560197461.000
##  Larrea tridentata - square      0.191 3.89e-15 26669   49055900052129.000
##  Larrea tridentata - triangle   -0.249 2.59e-15 26669  -96132127831242.000
##  open - square                   0.920 3.95e-15 26669  233076660025633.000
##  open - triangle                 0.481 2.68e-15 26669  179213272908776.000
##  square - triangle              -0.440 3.94e-15 26669 -111476256624597.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
A5/B5/C5
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).

temp_mojave2022<- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/Mojave_2022.csv")

temp_mojave2022_final <- inner_join(temp_mojave2022, richness_mojave2022, by = "microsite")

temp_mojave2022_final <- inner_join(temp_mojave2022_final, evenness_mojave2022, by = "microsite")

A6<-ggplot(temp_mojave2023_final, aes(x=richness, y=temp, fill = microsite)) + geom_boxplot()+ xlab("Richness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)


glm_6.1<-glm(formula = richness ~ temp*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_6.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      26676      12027             
## temp                       1    604.3     26675      11422   <2e-16 ***
## as.factor(microsite)       3  11422.4     26672          0   <2e-16 ***
## temp:as.factor(microsite)  3      0.0     26669          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_6.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata      6 9.73e-15 26669        6        6
##  open                   5 1.04e-14 26669        5        5
##  square                 4 1.90e-14 26669        4        4
##  triangle               6 1.04e-14 26669        6        6
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df             t.ratio
##  Larrea tridentata - open            1 1.43e-14 26669  70066546269864.000
##  Larrea tridentata - square          2 2.14e-14 26669  93592911720361.000
##  Larrea tridentata - triangle        0 1.42e-14 26669               1.000
##  open - square                       1 2.17e-14 26669  46072540267475.000
##  open - triangle                    -1 1.47e-14 26669 -67842498871048.000
##  square - triangle                  -2 2.17e-14 26669 -92232101206075.000
##  p.value
##   <.0001
##   <.0001
##   0.6182
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
B6<-ggplot(temp_mojave2023_final, aes(x=animals, y=temp, fill = microsite)) + geom_boxplot()+ xlab("Abundance") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_6.2<-glm(formula = animals ~ temp*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_6.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                      26676   16686006             
## temp                       1    97871     26675   16588135   <2e-16 ***
## as.factor(microsite)       3 16588135     26672          0   <2e-16 ***
## temp:as.factor(microsite)  3        0     26669          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_6.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata     53 2.32e-13 26669       53       53
##  open                  32 2.49e-13 26669       32       32
##  square                76 4.55e-13 26669       76       76
##  triangle              96 2.48e-13 26669       96       96
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open           21 3.41e-13 26669   61594819226064.000
##  Larrea tridentata - square        -23 5.10e-13 26669  -45056243317339.000
##  Larrea tridentata - triangle      -43 3.40e-13 26669 -126398712668319.000
##  open - square                     -44 5.18e-13 26669  -84861169821908.000
##  open - triangle                   -64 3.52e-13 26669 -181759027178838.000
##  square - triangle                 -20 5.18e-13 26669  -38609687117316.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
C6<-ggplot(temp_mojave2023_final, aes(evenness, y=temp, fill = microsite)) + geom_boxplot()+ xlab("Evenness") +
  ylab("Temperature (°C)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_6.3<-glm(formula = evenness ~ temp*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_6.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                           Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                      26676     2804.8              
## temp                       1     34.0     26675     2770.8 < 2.2e-16 ***
## as.factor(microsite)       3   2770.8     26672        0.0 < 2.2e-16 ***
## temp:as.factor(microsite)  3      0.0     26669        0.0 1.771e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_6.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata  0.741 1.77e-15 26669    0.741    0.741
##  open               1.470 1.90e-15 26669    1.470    1.470
##  square             0.550 3.46e-15 26669    0.550    0.550
##  triangle           0.990 1.89e-15 26669    0.990    0.990
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open       -0.730 2.60e-15 26669 -281010560197461.000
##  Larrea tridentata - square      0.191 3.89e-15 26669   49055900052129.000
##  Larrea tridentata - triangle   -0.249 2.59e-15 26669  -96132127831242.000
##  open - square                   0.920 3.95e-15 26669  233076660025633.000
##  open - triangle                 0.481 2.68e-15 26669  179213272908776.000
##  square - triangle              -0.440 3.94e-15 26669 -111476256624597.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
A6/B6/C6
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).

###now compare humidity to abundance, richness, and evenness data
###no humidity data for Mojave and Carrizo Winter 2023

###Carrizo 2023
D1<-ggplot(temp_carrizo2023_final, aes(x=richness, y=humidity, fill = microsite)) + 
  geom_boxplot()+ xlab("Richness") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_7.1<-glm(formula = richness ~ humidity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_7.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                          24190     118416              
## humidity                       1       65     24189     118351 < 2.2e-16 ***
## as.factor(microsite)           3   118351     24186          0 < 2.2e-16 ***
## humidity:as.factor(microsite)  3        0     24183          0 3.511e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_7.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica      4 4.43e-15 24183        4        4
##  open                     6 4.68e-15 24183        6        6
##  square                   7 3.78e-15 24183        7        7
##  triangle                10 3.59e-15 24183       10       10
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df               t.ratio
##  Ephedra californica - open           -2 6.45e-15 24183  -310141679974640.000
##  Ephedra californica - square         -3 5.83e-15 24183  -514960960624190.000
##  Ephedra californica - triangle       -6 5.71e-15 24183 -1051406810990360.000
##  open - square                        -1 6.02e-15 24183  -166222419696377.000
##  open - triangle                      -4 5.90e-15 24183  -677870444027862.000
##  square - triangle                    -3 5.21e-15 24183  -575508029041332.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
D2<-ggplot(temp_carrizo2023_final, aes(x=animals, y=humidity, fill = microsite)) + 
  geom_boxplot()+ xlab("Abundance") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_7.2<-glm(formula = animals ~ humidity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_7.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                          24190     118416              
## humidity                       1       65     24189     118351 < 2.2e-16 ***
## as.factor(microsite)           3   118351     24186          0 < 2.2e-16 ***
## humidity:as.factor(microsite)  3        0     24183          0 3.511e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_7.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica     36 1.09e-13 24183       36       36
##  open                    35 1.15e-13 24183       35       35
##  square                 228 9.29e-14 24183      228      228
##  triangle               212 8.83e-14 24183      212      212
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df               t.ratio
##  Ephedra californica - open            1 1.59e-13 24183     6305938161382.000
##  Ephedra californica - square       -192 1.43e-13 24183 -1340213068447762.000
##  Ephedra californica - triangle     -176 1.40e-13 24183 -1254156610645360.000
##  open - square                      -193 1.48e-13 24183 -1304567266464558.000
##  open - triangle                    -177 1.45e-13 24183 -1219774476977153.000
##  square - triangle                    16 1.28e-13 24183   124815834029916.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
D3<-ggplot(temp_carrizo2023_final, aes(x=evenness, y=humidity, fill = microsite)) + 
  geom_boxplot()+ xlab("Evenness") +
  ylab("Humidity(%)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_7.3<-glm(formula = evenness ~ humidity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_7.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                          24190     203.49             
## humidity                       1    0.007     24189     203.48  < 2e-16 ***
## as.factor(microsite)           3  203.481     24186       0.00  < 2e-16 ***
## humidity:as.factor(microsite)  3    0.000     24183       0.00  0.00223 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_7.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica   1.35 8.32e-15 24183     1.35     1.35
##  open                  1.34 8.78e-15 24183     1.34     1.34
##  square                1.26 7.08e-15 24183     1.26     1.26
##  triangle              1.49 6.74e-15 24183     1.49     1.49
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df             t.ratio
##  Ephedra californica - open       0.0187 1.21e-14 24183   1544138575133.000
##  Ephedra californica - square     0.0992 1.09e-14 24183   9077555324693.000
##  Ephedra californica - triangle  -0.1332 1.07e-14 24183 -12450038490181.000
##  open - square                    0.0805 1.13e-14 24183   7135153620595.000
##  open - triangle                 -0.1519 1.11e-14 24183 -13727811801274.000
##  square - triangle               -0.2324 9.77e-15 24183 -23774401186530.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
D1/D2/D3
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_summary()`).

E1<-ggplot(temp_carrizo2022_final, aes(x=richness, y=humidity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Richness") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_8.1<-glm(formula = richness ~ humidity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_8.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                          24190     118416              
## humidity                       1       65     24189     118351 < 2.2e-16 ***
## as.factor(microsite)           3   118351     24186          0 < 2.2e-16 ***
## humidity:as.factor(microsite)  3        0     24183          0 3.511e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_8.1,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica      4 4.43e-15 24183        4        4
##  open                     6 4.68e-15 24183        6        6
##  square                   7 3.78e-15 24183        7        7
##  triangle                10 3.59e-15 24183       10       10
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df               t.ratio
##  Ephedra californica - open           -2 6.45e-15 24183  -310141679974640.000
##  Ephedra californica - square         -3 5.83e-15 24183  -514960960624190.000
##  Ephedra californica - triangle       -6 5.71e-15 24183 -1051406810990360.000
##  open - square                        -1 6.02e-15 24183  -166222419696377.000
##  open - triangle                      -4 5.90e-15 24183  -677870444027862.000
##  square - triangle                    -3 5.21e-15 24183  -575508029041332.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
E2<-ggplot(temp_carrizo2022_final, aes(x=animals, y=humidity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Abundance") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_8.2<-glm(formula = animals ~ humidity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_8.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df  Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                           24190  196958140             
## humidity                       1    330987     24189  196627153   <2e-16 ***
## as.factor(microsite)           3 196627153     24186          0   <2e-16 ***
## humidity:as.factor(microsite)  3         0     24183          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_8.2,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica     36 1.09e-13 24183       36       36
##  open                    35 1.15e-13 24183       35       35
##  square                 228 9.29e-14 24183      228      228
##  triangle               212 8.83e-14 24183      212      212
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df               t.ratio
##  Ephedra californica - open            1 1.59e-13 24183     6305938161382.000
##  Ephedra californica - square       -192 1.43e-13 24183 -1340213068447762.000
##  Ephedra californica - triangle     -176 1.40e-13 24183 -1254156610645360.000
##  open - square                      -193 1.48e-13 24183 -1304567266464558.000
##  open - triangle                    -177 1.45e-13 24183 -1219774476977153.000
##  square - triangle                    16 1.28e-13 24183   124815834029916.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
E3<-ggplot(temp_carrizo2022_final, aes(x=evenness, y=humidity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Evenness") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_8.3<-glm(formula = evenness ~ humidity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_8.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                          24190     203.49             
## humidity                       1    0.007     24189     203.48  < 2e-16 ***
## as.factor(microsite)           3  203.481     24186       0.00  < 2e-16 ***
## humidity:as.factor(microsite)  3    0.000     24183       0.00  0.00223 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_8.3,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica   1.35 8.32e-15 24183     1.35     1.35
##  open                  1.34 8.78e-15 24183     1.34     1.34
##  square                1.26 7.08e-15 24183     1.26     1.26
##  triangle              1.49 6.74e-15 24183     1.49     1.49
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df             t.ratio
##  Ephedra californica - open       0.0187 1.21e-14 24183   1544138575133.000
##  Ephedra californica - square     0.0992 1.09e-14 24183   9077555324693.000
##  Ephedra californica - triangle  -0.1332 1.07e-14 24183 -12450038490181.000
##  open - square                    0.0805 1.13e-14 24183   7135153620595.000
##  open - triangle                 -0.1519 1.11e-14 24183 -13727811801274.000
##  square - triangle               -0.2324 9.77e-15 24183 -23774401186530.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
E1/E2/E3
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_summary()`).

F1<-ggplot(temp_mojave2023_final, aes(x=richness, y=humidity, fill = microsite)) + geom_boxplot()+ xlab("Richness") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)


glm_9.1<-glm(formula = richness ~ humidity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_9.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                          17456      11777              
## humidity                       1      7.1     17455      11770 < 2.2e-16 ***
## as.factor(microsite)           3  11769.7     17452          0 < 2.2e-16 ***
## humidity:as.factor(microsite)  3      0.0     17449          0 8.224e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_9.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata      6 1.28e-14 17449        6        6
##  open                   5 1.17e-14 17449        5        5
##  square                 4 1.17e-14 17449        4        4
##  triangle               6 9.53e-15 17449        6        6
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open            1 1.73e-14 17449   57728527495214.000
##  Larrea tridentata - square          2 1.73e-14 17449  115426741239377.000
##  Larrea tridentata - triangle        0 1.60e-14 17449                1.000
##  open - square                       1 1.65e-14 17449   60532866685042.000
##  open - triangle                    -1 1.51e-14 17449  -66349617340108.000
##  square - triangle                  -2 1.51e-14 17449 -132653216587306.000
##  p.value
##   <.0001
##   <.0001
##   0.7472
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
F2<-ggplot(temp_mojave2023_final, aes(x=animals, y=humidity, fill = microsite)) + geom_boxplot()+ xlab("Abundance") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_9.2<-glm(formula = animals ~ humidity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_9.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                          17456   10965960              
## humidity                       1     1057     17455   10964903 < 2.2e-16 ***
## as.factor(microsite)           3 10964903     17452          0 < 2.2e-16 ***
## humidity:as.factor(microsite)  3        0     17449          0  0.005268 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_9.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata     53 2.43e-13 17449       53       53
##  open                  32 2.22e-13 17449       32       32
##  square                76 2.22e-13 17449       76       76
##  triangle              96 1.81e-13 17449       96       96
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open           21 3.30e-13 17449   63731984836151.000
##  Larrea tridentata - square        -23 3.30e-13 17449  -69783370938917.000
##  Larrea tridentata - triangle      -43 3.03e-13 17449 -141708615273037.000
##  open - square                     -44 3.14e-13 17449 -140020488176199.000
##  open - triangle                   -64 2.87e-13 17449 -223236942634324.000
##  square - triangle                 -20 2.87e-13 17449  -69737352321875.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
F3<-ggplot(temp_mojave2023_final, aes(evenness, y=humidity, fill = microsite)) + geom_boxplot()+ xlab("Evenness") +
  ylab("Humidity (%)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_9.3<-glm(formula = evenness ~ humidity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_9.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                               Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                          17456     1890.2             
## humidity                       1     0.15     17455     1890.1   <2e-16 ***
## as.factor(microsite)           3  1890.07     17452        0.0   <2e-16 ***
## humidity:as.factor(microsite)  3     0.00     17449        0.0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_9.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata  0.741 4.54e-16 17449    0.741    0.741
##  open               1.470 4.14e-16 17449    1.470    1.470
##  square             0.550 4.15e-16 17449    0.550    0.550
##  triangle           0.990 3.38e-16 17449    0.990    0.990
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df               t.ratio
##  Larrea tridentata - open       -0.730 6.15e-16 17449 -1186726500699234.000
##  Larrea tridentata - square      0.191 6.15e-16 17449   310100848951874.000
##  Larrea tridentata - triangle   -0.249 5.66e-16 17449  -439882717657416.000
##  open - square                   0.920 5.86e-16 17449  1569625696643090.000
##  open - triangle                 0.481 5.35e-16 17449   898369478040840.000
##  square - triangle              -0.440 5.35e-16 17449  -821800289558537.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
F1/F2/F3
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_summary()`).

###No logger humidity data for Mojave 2022 because loggers did not record.
###let's test abundance, richness, and evenness against light intensity


G1<-ggplot(temp_mojave2023_winter_final, aes(x=richness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+xlab("Richness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_10.1<-glm(formula = richness ~ intensity*as.factor(microsite), data = temp_mojave2023_winter_final)
anova(glm_10.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                            1042     229.17             
## intensity                       1    1.324      1041     227.84   <2e-16 ***
## as.factor(microsite)            1  227.842      1040       0.00   <2e-16 ***
## intensity:as.factor(microsite)  1    0.000      1039       0.00   0.1976    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_10.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE   df lower.CL upper.CL
##  Larrea tridentata      1 1.09e-15 1039        1        1
##  square                 2 7.50e-16 1039        2        2
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                   estimate       SE   df              t.ratio p.value
##  Larrea tridentata - square       -1 1.32e-15 1039 -756312420321572.000  <.0001
G2<-ggplot(temp_mojave2023_winter_final, aes(x=animals, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+xlab("Abundance") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_10.2<-glm(formula = animals ~ intensity*as.factor(microsite), data = temp_mojave2023_winter_final)
anova(glm_10.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df   Deviance Resid. Df Resid. Dev Pr(>Chi)  
## NULL                                              1042 0.0000e+00           
## intensity                       1 0.0000e+00      1041 2.3635e-24  1.00000  
## as.factor(microsite)            1 0.0000e+00      1040 2.3870e-24  1.00000  
## intensity:as.factor(microsite)  1 1.0982e-26      1039 2.3760e-24  0.02842 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_10.2, pairwise ~ as.factor(microsite)) 
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE   df lower.CL upper.CL
##  Larrea tridentata      3 2.62e-15 1039        3        3
##  square                 3 1.81e-15 1039        3        3
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                    estimate       SE   df t.ratio p.value
##  Larrea tridentata - square -4.05e-15 3.18e-15 1039  -1.273  0.2033
G3<-ggplot(temp_mojave2023_winter_final, aes(x=evenness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+xlab("Evenness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_10.3<-glm(formula = evenness ~ intensity*as.factor(microsite), data = temp_mojave2023_winter_final)
anova(glm_10.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                            1042     92.847             
## intensity                       1    0.536      1041     92.310   <2e-16 ***
## as.factor(microsite)            1   92.310      1040      0.000   <2e-16 ***
## intensity:as.factor(microsite)  1    0.000      1039      0.000        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_10.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean      SE   df lower.CL upper.CL
##  Larrea tridentata  0.000 6.1e-16 1039    0.000    0.000
##  square             0.637 4.2e-16 1039    0.637    0.637
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                   estimate      SE   df              t.ratio p.value
##  Larrea tridentata - square   -0.637 7.4e-16 1039 -859715171204072.000  <.0001
G1/G2/G3

H1<-ggplot(temp_carrizo2023_winter_final, aes(x=richness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+ xlab("Richness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_11.1<-glm(formula = richness ~ intensity*as.factor(microsite), data = temp_carrizo2023_winter_final)
anova(glm_11.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                            2019     1766.8             
## intensity                       1    36.46      2018     1730.3   <2e-16 ***
## as.factor(microsite)            2  1730.32      2016        0.0   <2e-16 ***
## intensity:as.factor(microsite)  2     0.00      2014        0.0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_11.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE   df lower.CL upper.CL
##  Ephedra californica      8 2.18e-15 2014        8        8
##  square                   5 8.11e-16 2014        5        5
##  triangle                 6 8.08e-16 2014        6        6
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE   df              t.ratio
##  Ephedra californica - square          3 2.32e-15 2014 1290722542352364.000
##  Ephedra californica - triangle        2 2.32e-15 2014  860972325142544.000
##  square - triangle                    -1 1.14e-15 2014 -873448949532552.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
H2<-ggplot(temp_carrizo2023_winter_final, aes(x=animals, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+ xlab("Abundance") +
  ylab("Radiation (lum/ft²)")+
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_11.2<-glm(formula = animals ~ intensity*as.factor(microsite), data = temp_carrizo2023_winter_final)
anova(glm_11.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                            2019    1563902             
## intensity                       1    30286      2018    1533616   <2e-16 ***
## as.factor(microsite)            2  1533616      2016          0   <2e-16 ***
## intensity:as.factor(microsite)  2        0      2014          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_11.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE   df lower.CL upper.CL
##  Ephedra californica    103 1.07e-13 2014      103      103
##  square                  13 4.00e-14 2014       13       13
##  triangle                24 3.98e-14 2014       24       24
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE   df              t.ratio
##  Ephedra californica - square         90 1.15e-13 2014  785516494706426.000
##  Ephedra californica - triangle       79 1.15e-13 2014  689902067960552.000
##  square - triangle                   -11 5.64e-14 2014 -194908765721400.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
H3<-ggplot(temp_carrizo2023_winter_final, aes(x=evenness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+ xlab("Evenness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA, size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_11.3<-glm(formula = evenness ~ intensity*as.factor(microsite), data = temp_carrizo2023_winter_final)
anova(glm_11.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                            2019   0.061377             
## intensity                       1 0.001127      2018   0.060250   <2e-16 ***
## as.factor(microsite)            2 0.060250      2016   0.000000   <2e-16 ***
## intensity:as.factor(microsite)  2 0.000000      2014   0.000000        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_11.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE   df lower.CL upper.CL
##  Ephedra californica   1.34 1.33e-17 2014     1.34     1.34
##  square                1.33 4.97e-18 2014     1.33     1.33
##  triangle              1.33 4.95e-18 2014     1.33     1.33
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE   df              t.ratio
##  Ephedra californica - square    0.01754 1.42e-17 2014 1231776973156428.000
##  Ephedra californica - triangle  0.01635 1.42e-17 2014 1148954846152655.000
##  square - triangle              -0.00119 7.02e-18 2014 -169469684677137.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
H1/H2/H3

I1<-ggplot(temp_carrizo2023_final, aes(x=richness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ xlab("Richness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_12.1<-glm(formula = richness ~ intensity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_12.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                           28584     117523             
## intensity                       1        0     28583     117522   <2e-16 ***
## as.factor(microsite)            3   117522     28580          0   <2e-16 ***
## intensity:as.factor(microsite)  3        0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_12.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica      4 3.67e-14 28577        4        4
##  open                     6 3.64e-14 28577        6        6
##  square                   7 2.42e-14 28577        7        7
##  triangle                10 2.92e-14 28577       10       10
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open           -2 5.17e-14 28577  -38654899326517.000
##  Ephedra californica - square         -3 4.40e-14 28577  -68170270047057.000
##  Ephedra californica - triangle       -6 4.69e-14 28577 -127931935651836.000
##  open - square                        -1 4.38e-14 28577  -22847106362120.000
##  open - triangle                      -4 4.67e-14 28577  -85696283577158.000
##  square - triangle                    -3 3.79e-14 28577  -79102734320028.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
I2<-ggplot(temp_carrizo2023_final, aes(x=animals, y=intensity, fill = microsite)) + 
  geom_boxplot()+ xlab("Abundance") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_12.2<-glm(formula = animals ~ intensity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_12.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df  Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                            28584  223625068             
## intensity                       1   1283469     28583  222341599   <2e-16 ***
## as.factor(microsite)            3 222341599     28580          0   <2e-16 ***
## intensity:as.factor(microsite)  3         0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_12.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica     36 8.96e-13 28577       36       36
##  open                    35 8.89e-13 28577       35       35
##  square                 228 5.91e-13 28577      228      228
##  triangle               212 7.11e-13 28577      212      212
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open            1 1.26e-12 28577     792330183285.000
##  Ephedra californica - square       -192 1.07e-12 28577 -178857286614291.000
##  Ephedra californica - triangle     -176 1.14e-12 28577 -153840980049092.000
##  open - square                      -193 1.07e-12 28577 -180767421020377.000
##  open - triangle                    -177 1.14e-12 28577 -155455793787529.000
##  square - triangle                    16 9.25e-13 28577   17295052049429.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
I3<-ggplot(temp_carrizo2023_final, aes(x=evenness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ xlab("Evenness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_12.3<-glm(formula = evenness ~ intensity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_12.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                           28584     246.36              
## intensity                       1    2.043     28583     244.32 < 2.2e-16 ***
## as.factor(microsite)            3  244.319     28580       0.00 < 2.2e-16 ***
## intensity:as.factor(microsite)  3    0.000     28577       0.00  0.002801 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_12.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica   1.35 1.32e-15 28577     1.35     1.35
##  open                  1.34 1.31e-15 28577     1.34     1.34
##  square                1.26 8.68e-16 28577     1.26     1.26
##  triangle              1.49 1.04e-15 28577     1.49     1.49
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open       0.0187 1.85e-15 28577   10074726208647.000
##  Ephedra californica - square     0.0992 1.58e-15 28577   62906016017117.000
##  Ephedra californica - triangle  -0.1332 1.68e-15 28577  -79301508296744.000
##  open - square                    0.0805 1.57e-15 28577   51339011222917.000
##  open - triangle                 -0.1519 1.67e-15 28577  -90848795737773.000
##  square - triangle               -0.2324 1.36e-15 28577 -171061495512515.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
I1/I2/I3
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).

J1<-ggplot(temp_carrizo2022_final, aes(x=richness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Richness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Carrizo 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_13.1<-glm(formula = richness ~ intensity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_13.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                           28584     117523             
## intensity                       1        0     28583     117522   <2e-16 ***
## as.factor(microsite)            3   117522     28580          0   <2e-16 ***
## intensity:as.factor(microsite)  3        0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_13.1,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica      4 3.67e-14 28577        4        4
##  open                     6 3.64e-14 28577        6        6
##  square                   7 2.42e-14 28577        7        7
##  triangle                10 2.92e-14 28577       10       10
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open           -2 5.17e-14 28577  -38654899326517.000
##  Ephedra californica - square         -3 4.40e-14 28577  -68170270047057.000
##  Ephedra californica - triangle       -6 4.69e-14 28577 -127931935651836.000
##  open - square                        -1 4.38e-14 28577  -22847106362120.000
##  open - triangle                      -4 4.67e-14 28577  -85696283577158.000
##  square - triangle                    -3 3.79e-14 28577  -79102734320028.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
J2<-ggplot(temp_carrizo2022_final, aes(x=animals, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Abundance") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_13.2<-glm(formula = animals ~ intensity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_13.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df  Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                            28584  223625068             
## intensity                       1   1283469     28583  222341599   <2e-16 ***
## as.factor(microsite)            3 222341599     28580          0   <2e-16 ***
## intensity:as.factor(microsite)  3         0     28577          0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_13.2,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica     36 8.96e-13 28577       36       36
##  open                    35 8.89e-13 28577       35       35
##  square                 228 5.91e-13 28577      228      228
##  triangle               212 7.11e-13 28577      212      212
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open            1 1.26e-12 28577     792330183285.000
##  Ephedra californica - square       -192 1.07e-12 28577 -178857286614291.000
##  Ephedra californica - triangle     -176 1.14e-12 28577 -153840980049092.000
##  open - square                      -193 1.07e-12 28577 -180767421020377.000
##  open - triangle                    -177 1.14e-12 28577 -155455793787529.000
##  square - triangle                    16 9.25e-13 28577   17295052049429.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
J3<-ggplot(temp_carrizo2022_final, aes(x=evenness, y=intensity, fill = microsite)) + 
  geom_boxplot()+ theme_classic()+  xlab("Evenness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)
glm_13.3<-glm(formula = evenness ~ intensity*as.factor(microsite), data = temp_carrizo2023_final)
anova(glm_13.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                           28584     246.36              
## intensity                       1    2.043     28583     244.32 < 2.2e-16 ***
## as.factor(microsite)            3  244.319     28580       0.00 < 2.2e-16 ***
## intensity:as.factor(microsite)  3    0.000     28577       0.00  0.002801 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_13.3,pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite           emmean       SE    df lower.CL upper.CL
##  Ephedra californica   1.35 1.32e-15 28577     1.35     1.35
##  open                  1.34 1.31e-15 28577     1.34     1.34
##  square                1.26 8.68e-16 28577     1.26     1.26
##  triangle              1.49 1.04e-15 28577     1.49     1.49
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate       SE    df              t.ratio
##  Ephedra californica - open       0.0187 1.85e-15 28577   10074726208647.000
##  Ephedra californica - square     0.0992 1.58e-15 28577   62906016017117.000
##  Ephedra californica - triangle  -0.1332 1.68e-15 28577  -79301508296744.000
##  open - square                    0.0805 1.57e-15 28577   51339011222917.000
##  open - triangle                 -0.1519 1.67e-15 28577  -90848795737773.000
##  square - triangle               -0.2324 1.36e-15 28577 -171061495512515.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
J1/J2/J3
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).

K1<-ggplot(temp_mojave2023_final, aes(x=richness, y=intensity, fill = microsite)) + geom_boxplot()+ xlab("Richness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_14.1<-glm(formula = richness ~ intensity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_14.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                           26676      12027              
## intensity                       1     78.9     26675      11948 < 2.2e-16 ***
## as.factor(microsite)            3  11947.8     26672          0 < 2.2e-16 ***
## intensity:as.factor(microsite)  3      0.0     26669          0 5.821e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_14.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata      6 9.88e-15 26669        6        6
##  open                   5 1.08e-14 26669        5        5
##  square                 4 2.23e-14 26669        4        4
##  triangle               6 1.08e-14 26669        6        6
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df             t.ratio
##  Larrea tridentata - open            1 1.46e-14 26669  68276363057903.000
##  Larrea tridentata - square          2 2.44e-14 26669  82021098682619.000
##  Larrea tridentata - triangle        0 1.46e-14 26669               1.000
##  open - square                       1 2.48e-14 26669  40361904900326.000
##  open - triangle                    -1 1.53e-14 26669 -65481424159355.000
##  square - triangle                  -2 2.48e-14 26669 -80760722849789.000
##  p.value
##   <.0001
##   <.0001
##   0.8410
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
K2<-ggplot(temp_mojave2023_final, aes(x=animals, y=intensity, fill = microsite)) + geom_boxplot()+ xlab("Abundance") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_14.2<-glm(formula = animals ~ intensity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_14.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                           26676   16686006              
## intensity                       1    16539     26675   16669466 < 2.2e-16 ***
## as.factor(microsite)            3 16669466     26672          0 < 2.2e-16 ***
## intensity:as.factor(microsite)  3        0     26669          0 3.927e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_14.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata     53 2.30e-13 26669       53       53
##  open                  32 2.52e-13 26669       32       32
##  square                76 5.19e-13 26669       76       76
##  triangle              96 2.51e-13 26669       96       96
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open           21 3.41e-13 26669   61553590078932.000
##  Larrea tridentata - square        -23 5.68e-13 26669  -40493669781504.000
##  Larrea tridentata - triangle      -43 3.41e-13 26669 -126203436282411.000
##  open - square                     -44 5.77e-13 26669  -76240905457029.000
##  open - triangle                   -64 3.56e-13 26669 -179912693087451.000
##  square - triangle                 -20 5.77e-13 26669  -34670803901002.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
K3<-ggplot(temp_mojave2023_final, aes(evenness, y=intensity, fill = microsite)) + geom_boxplot()+ xlab("Evenness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") +stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_14.3<-glm(formula = evenness ~ intensity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_14.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                           26676     2804.8             
## intensity                       1     5.99     26675     2798.8   <2e-16 ***
## as.factor(microsite)            3  2798.83     26672        0.0   <2e-16 ***
## intensity:as.factor(microsite)  3     0.00     26669        0.0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_14.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata  0.741 1.77e-15 26669    0.741    0.741
##  open               1.470 1.93e-15 26669    1.470    1.470
##  square             0.550 3.98e-15 26669    0.550    0.550
##  triangle           0.990 1.93e-15 26669    0.990    0.990
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open       -0.730 2.62e-15 26669 -278702292199344.000
##  Larrea tridentata - square      0.191 4.36e-15 26669   43755444861400.000
##  Larrea tridentata - triangle   -0.249 2.61e-15 26669  -95258948081731.000
##  open - square                   0.920 4.43e-15 26669  207819604543198.000
##  open - triangle                 0.481 2.73e-15 26669  176053507957207.000
##  square - triangle              -0.440 4.43e-15 26669  -99347902609623.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
K1/K2/K3
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).

L1<-ggplot(temp_mojave2023_final, aes(x=richness, y=intensity, fill = microsite)) + geom_boxplot()+ xlab("Richness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ ggtitle('Mojave 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)


glm_15.1<-glm(formula = richness ~ intensity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_15.1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: richness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                           26676      12027              
## intensity                       1     78.9     26675      11948 < 2.2e-16 ***
## as.factor(microsite)            3  11947.8     26672          0 < 2.2e-16 ***
## intensity:as.factor(microsite)  3      0.0     26669          0 5.821e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_15.1, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata      6 9.88e-15 26669        6        6
##  open                   5 1.08e-14 26669        5        5
##  square                 4 2.23e-14 26669        4        4
##  triangle               6 1.08e-14 26669        6        6
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df             t.ratio
##  Larrea tridentata - open            1 1.46e-14 26669  68276363057903.000
##  Larrea tridentata - square          2 2.44e-14 26669  82021098682619.000
##  Larrea tridentata - triangle        0 1.46e-14 26669               1.000
##  open - square                       1 2.48e-14 26669  40361904900326.000
##  open - triangle                    -1 1.53e-14 26669 -65481424159355.000
##  square - triangle                  -2 2.48e-14 26669 -80760722849789.000
##  p.value
##   <.0001
##   <.0001
##   0.8410
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
L2<-ggplot(temp_mojave2023_final, aes(x=animals, y=intensity, fill = microsite)) + geom_boxplot()+ xlab("Abundance") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_15.2<-glm(formula = animals ~ intensity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_15.2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: animals
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                                           26676   16686006              
## intensity                       1    16539     26675   16669466 < 2.2e-16 ***
## as.factor(microsite)            3 16669466     26672          0 < 2.2e-16 ***
## intensity:as.factor(microsite)  3        0     26669          0 3.927e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_15.2, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata     53 2.30e-13 26669       53       53
##  open                  32 2.52e-13 26669       32       32
##  square                76 5.19e-13 26669       76       76
##  triangle              96 2.51e-13 26669       96       96
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open           21 3.41e-13 26669   61553590078932.000
##  Larrea tridentata - square        -23 5.68e-13 26669  -40493669781504.000
##  Larrea tridentata - triangle      -43 3.41e-13 26669 -126203436282411.000
##  open - square                     -44 5.77e-13 26669  -76240905457029.000
##  open - triangle                   -64 3.56e-13 26669 -179912693087451.000
##  square - triangle                 -20 5.77e-13 26669  -34670803901002.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
L3<-ggplot(temp_mojave2023_final, aes(evenness, y=intensity, fill = microsite)) + geom_boxplot()+ xlab("Evenness") +
  ylab("Radiation (lum/ft²)") +
  labs(fill = "Microsite") + theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) + theme(legend.position = "none") + stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE)

glm_15.3<-glm(formula = evenness ~ intensity*as.factor(microsite), data = temp_mojave2023_final)
anova(glm_15.3, test = "Chisq")
## Analysis of Deviance Table
## 
## Model: gaussian, link: identity
## 
## Response: evenness
## 
## Terms added sequentially (first to last)
## 
## 
##                                Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
## NULL                                           26676     2804.8             
## intensity                       1     5.99     26675     2798.8   <2e-16 ***
## as.factor(microsite)            3  2798.83     26672        0.0   <2e-16 ***
## intensity:as.factor(microsite)  3     0.00     26669        0.0        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(glm_15.3, pairwise ~ as.factor(microsite))
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
##  microsite         emmean       SE    df lower.CL upper.CL
##  Larrea tridentata  0.741 1.77e-15 26669    0.741    0.741
##  open               1.470 1.93e-15 26669    1.470    1.470
##  square             0.550 3.98e-15 26669    0.550    0.550
##  triangle           0.990 1.93e-15 26669    0.990    0.990
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate       SE    df              t.ratio
##  Larrea tridentata - open       -0.730 2.62e-15 26669 -278702292199344.000
##  Larrea tridentata - square      0.191 4.36e-15 26669   43755444861400.000
##  Larrea tridentata - triangle   -0.249 2.61e-15 26669  -95258948081731.000
##  open - square                   0.920 4.43e-15 26669  207819604543198.000
##  open - triangle                 0.481 2.73e-15 26669  176053507957207.000
##  square - triangle              -0.440 4.43e-15 26669  -99347902609623.000
##  p.value
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
##   <.0001
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
L1/L2/L3
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).

###explore the relationship between light and temperature to use temperature as a proxy for animal observations models

cor.test(temp_mojave2022_final$temp,temp_mojave2022_final$intensity, method = "kendall")#positively correlated
## 
##  Kendall's rank correlation tau
## 
## data:  temp_mojave2022_final$temp and temp_mojave2022_final$intensity
## z = 83.161, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## 0.5790353
cor.test(temp_mojave2023_final$temp,temp_mojave2023_final$intensity, method = "kendall")#positively correlated 
## 
##  Kendall's rank correlation tau
## 
## data:  temp_mojave2023_final$temp and temp_mojave2023_final$intensity
## z = 121.02, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## 0.5238221
cor.test(temp_carrizo2022_final$temp,temp_carrizo2022_final$intensity, method = "kendall")#positively correlated
## 
##  Kendall's rank correlation tau
## 
## data:  temp_carrizo2022_final$temp and temp_carrizo2022_final$intensity
## z = 158.58, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## 0.6296155
cor.test(temp_carrizo2023_final$temp,temp_carrizo2023_final$intensity, method = "kendall")#positively correlated
## 
##  Kendall's rank correlation tau
## 
## data:  temp_carrizo2023_final$temp and temp_carrizo2023_final$intensity
## z = 148.04, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## 0.6177645
cor.test(temp_mojave2023_winter_final$temp,temp_mojave2023_winter_final$intensity, method = "kendall")#positively correlated 
## 
##  Kendall's rank correlation tau
## 
## data:  temp_mojave2023_winter_final$temp and temp_mojave2023_winter_final$intensity
## z = 19.177, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## 0.4349724
cor.test(temp_carrizo2023_winter_final$temp,temp_carrizo2023_winter_final$intensity, method = "kendall")#positively correlated 
## 
##  Kendall's rank correlation tau
## 
## data:  temp_carrizo2023_winter_final$temp and temp_carrizo2023_winter_final$intensity
## z = 37.586, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## 0.6078502
###Thus, we will use temperature as a proxy for light intensity in models.
###SUPPLEMENTARY PLOT
###Temperature
library(ggpubr)
## 
## Attaching package: 'ggpubr'
## The following object is masked from 'package:ape':
## 
##     rotate
ggqqplot(temp_carrizo2022_final$humidity)
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 31542 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 31542 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_carrizo2022_final$humidity)#right-skewed

ggqqplot(temp_carrizo2023_final$humidity)
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 28587 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 28587 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_carrizo2023_final$humidity)#right-skewed

ggqqplot(temp_carrizo2023_winter_final$temp)

hist(temp_carrizo2023_winter_final$temp)#right-skewed

ggqqplot(temp_mojave2022_final$temp)

hist(temp_mojave2022_final$temp)#right-skewed

ggqqplot(temp_mojave2023_final$temp)
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 17457 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_mojave2023_final$temp)#right-skewed

ggqqplot(temp_mojave2023_winter_final$temp)

hist(temp_mojave2023_winter_final$temp)#right-skewed

###Humidity
ggqqplot(temp_carrizo2022_final$temp)
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 1788 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_carrizo2022_final$temp)#right-skewed

ggqqplot(temp_carrizo2023_final$temp)
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 24193 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_carrizo2023_final$temp)#bimodal distribution 

ggqqplot(temp_mojave2023_final$humidity)
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 26677 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_mojave2023_final$humidity)#right-skewed

###light intensity
ggqqplot(temp_carrizo2022_final$intensity)
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 1788 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_carrizo2022_final$intensity)#right-skewed

ggqqplot(temp_carrizo2023_final$intensity)
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 24193 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_carrizo2023_final$intensity)#right-skewed

ggqqplot(temp_carrizo2023_winter_final$intensity)

hist(temp_carrizo2023_winter_final$intensity)#right-skewed

ggqqplot(temp_mojave2022_final$intensity)

hist(temp_mojave2022_final$intensity)#right-skewed

ggqqplot(temp_mojave2023_final$intensity)
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_qq()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_qq_line()`).
## Removed 17457 rows containing non-finite outside the scale range
## (`stat_qq_line()`).

hist(temp_mojave2023_final$intensity)#right-skewed

ggqqplot(temp_mojave2023_winter_final$intensity)

hist(temp_mojave2023_winter_final$intensity)#right-skewed

### RII Carrizo 2022
###temp

temp_carrizo2022_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_carrizo2022_wide.csv")


rii.temp.shrub.carrizo2022<- temp_carrizo2022_wide %>%
  mutate(rii_calc_shrub = (temp.Ephedra.californica-temp.open)/(temp.Ephedra.californica + temp.open))

rii.temp.triangle.carrizo2022<- temp_carrizo2022_wide %>%
  mutate(rii_calc_triangle = (temp.triangle-temp.open)/(temp.triangle + temp.open)) 

rii.temp.square.carrizo2022<- temp_carrizo2022_wide %>%
  mutate(rii_calc_square = (temp.square-temp.open)/(temp.square+ temp.open)) 

x <- select(rii.temp.shrub.carrizo2022, rii_calc_shrub)
y <- select(rii.temp.triangle.carrizo2022, rii_calc_triangle)
z <- select(rii.temp.square.carrizo2022, rii_calc_square)
rii.final.temp.carrizo2022<-cbind(x, y, z)


write.csv(rii.final.temp.carrizo2022, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_carrizo2022.csv")


rii_carrizo2022_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_carrizo2022_manual.csv")


ggplot(rii_carrizo2022_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Temperature")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Carrizo 2022')+   labs(fill = "Microsite") + ylim(-0.4, 0.4)
## Warning: Removed 835 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 835 rows containing non-finite outside the scale range
## (`stat_summary()`).

library(ggpubr)

ggline(rii_carrizo2022_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Temperature", xlab = "Microsite", title = "Carrizo 2022")
## Warning: Removed 646 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_carrizo2022<- glm(rii~as.factor(microsite), data = rii_carrizo2022_manual, family="gaussian")

emmeans(lm_rii_carrizo2022, pairwise~microsite)
## $emmeans
##  microsite           emmean     SE  df lower.CL upper.CL
##  Ephedra californica  0.313 0.0893 218    0.137   0.4895
##  square              -0.183 0.1067 218   -0.393   0.0277
##  triangle            -0.447 0.0375 218   -0.521  -0.3729
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate     SE  df t.ratio p.value
##  Ephedra californica - square      0.496 0.1392 218   3.565  0.0013
##  Ephedra californica - triangle    0.760 0.0969 218   7.851  <.0001
##  square - triangle                 0.264 0.1131 218   2.336  0.0531
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
###only shrub was cooler than the open in Carrizo in 2022


### RII Carrizo 2023
###temp

temp_carrizo2023_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_carrizo2023_wide.csv")


rii.temp.shrub.carrizo2023<- temp_carrizo2023_wide %>%
  mutate(rii_calc_shrub = (temp.Ephedra.californica-temp.open)/(temp.Ephedra.californica + temp.open))

rii.temp.triangle.carrizo2023<- temp_carrizo2023_wide %>%
  mutate(rii_calc_triangle = (temp.triangle-temp.open)/(temp.triangle + temp.open)) 

rii.temp.square.carrizo2023<- temp_carrizo2023_wide %>%
  mutate(rii_calc_square = (temp.square-temp.open)/(temp.square+ temp.open)) 

x2<- select(rii.temp.shrub.carrizo2023, rii_calc_shrub)
y2<- select(rii.temp.triangle.carrizo2023, rii_calc_triangle)
z2<- select(rii.temp.square.carrizo2023, rii_calc_square)
rii.final.temp.carrizo2023<-cbind(x2, y2, z2)

write.csv(rii.final.temp.carrizo2023, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_carrizo2023.csv")


rii_carrizo2023_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_carrizo2023_manual.csv")

ggplot(rii_carrizo2023_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Temperature")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Carrizo 2023')  + ylim(-1,1) +   labs(fill = "Microsite") 
## Warning: Removed 9236 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 9236 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_carrizo2023_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Temperature", xlab = "Microsite", title = "Carrizo 2023")
## Warning: Removed 9201 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_carrizo2023<- glm(rii~as.factor(microsite), data = rii_carrizo2023_manual, family="gaussian")

emmeans(lm_rii_carrizo2023, pairwise~microsite)###only shrub was cooler than the open in Carrizo in 2023
## $emmeans
##  microsite            emmean     SE   df lower.CL upper.CL
##  Ephedra californica -0.0537 0.0287 2058  -0.1100  0.00249
##  square               0.0289 0.0282 2058  -0.0263  0.08417
##  triangle             0.0335 0.0282 2058  -0.0218  0.08871
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate     SE   df t.ratio p.value
##  Ephedra californica - square   -0.08266 0.0402 2058  -2.056  0.0994
##  Ephedra californica - triangle -0.08720 0.0402 2058  -2.169  0.0768
##  square - triangle              -0.00454 0.0398 2058  -0.114  0.9929
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
### RII Mojave 2022
###temp

temp_mojave2022_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_mojave2022_wide.csv")


rii.temp.shrub.mojave2022<- temp_mojave2022_wide %>%
  mutate(rii_calc_shrub = (temp.Larrea.tridentata-temp.open)/(temp.Larrea.tridentata + temp.open))

rii.temp.triangle.mojave2022<- temp_mojave2022_wide %>%
  mutate(rii_calc_triangle = (temp.triangle-temp.open)/(temp.triangle + temp.open)) 

rii.temp.square.mojave2022<- temp_mojave2022_wide %>%
  mutate(rii_calc_square = (temp.square-temp.open)/(temp.square+ temp.open)) 

x3<- select(rii.temp.shrub.mojave2022, rii_calc_shrub)
y3<- select(rii.temp.triangle.mojave2022, rii_calc_triangle)
z3<- select(rii.temp.square.mojave2022, rii_calc_square)
rii.final.temp.mojave2022<-cbind(x3, y3, z3)

write.csv(rii.final.temp.mojave2022, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_mojave2022.csv")


rii_mojave2022_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_mojave2022_manual.csv")

ggplot(rii_mojave2022_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Temperature")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Mojave 2022')+   labs(fill = "Microsite") 

ggline(rii_mojave2022_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Temperture", xlab = "Microsite", title = "Mojave 2022")

lm_rii_mojave2022<- glm(rii~as.factor(microsite), data = rii_mojave2022_manual, family="gaussian")

emmeans(lm_rii_mojave2022, pairwise~microsite)
## $emmeans
##  microsite            emmean     SE df lower.CL  upper.CL
##  Larrea tridentata -3.08e-02 0.0085 63  -0.0478 -0.013793
##  square            -1.61e-02 0.0085 63  -0.0331  0.000925
##  triangle           1.05e-05 0.0085 63  -0.0170  0.017001
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate    SE df t.ratio p.value
##  Larrea tridentata - square    -0.0147 0.012 63  -1.224  0.4436
##  Larrea tridentata - triangle  -0.0308 0.012 63  -2.561  0.0339
##  square - triangle             -0.0161 0.012 63  -1.337  0.3803
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
###only shrub and square were cooler than the open


### RII mojave 2023
###temp


temp_mojave2023_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_mojave2023_wide.csv")

rii_carrizo2023_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_carrizo2023_manual.csv")

rii.temp.shrub.mojave2023<- temp_mojave2023_wide %>%
  mutate(rii_calc_shrub = (temp.Larrea.tridentata-temp.open)/(temp.Larrea.tridentata + temp.open))

rii.temp.triangle.mojave2023<- temp_mojave2023_wide %>%
  mutate(rii_calc_triangle = (temp.triangle-temp.open)/(temp.triangle + temp.open)) 

rii.temp.square.mojave2023<- temp_mojave2023_wide %>%
  mutate(rii_calc_square = (temp.square-temp.open)/(temp.square+ temp.open)) 

x4<- select(rii.temp.shrub.mojave2023, rii_calc_shrub)
y4<- select(rii.temp.triangle.mojave2023, rii_calc_triangle)
z4<- select(rii.temp.square.mojave2023, rii_calc_square)
rii.final.temp.mojave2023<-cbind(x4, y4, z4)


rii_mojave2023_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_mojave2023_manual.csv")



ggplot(rii_mojave2023_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Temperature")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Mojave 2023')  + ylim(-0.5,0.5) +   labs(fill = "Microsite") 
## Warning: Removed 6129 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 6129 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_mojave2023_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Temperature", xlab = "Microsite", title = "Mojave 2023")
## Warning: Removed 6129 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_mojave2023<- glm(rii~as.factor(microsite), data = rii_mojave2023_manual, family="gaussian")

emmeans(lm_rii_mojave2023, pairwise~microsite)
## $emmeans
##  microsite            emmean      SE   df lower.CL upper.CL
##  Larrea tridentata -2.01e-03 0.00118 6231 -0.00433 0.000303
##  square             2.35e-03 0.00272 6231 -0.00298 0.007688
##  triangle           7.28e-05 0.00158 6231 -0.00302 0.003162
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate      SE   df t.ratio p.value
##  Larrea tridentata - square   -0.00436 0.00297 6231  -1.471  0.3051
##  Larrea tridentata - triangle -0.00209 0.00197 6231  -1.059  0.5397
##  square - triangle             0.00228 0.00315 6231   0.725  0.7489
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
###let's try RII for radiation for carrizo 2022

intensity_carrizo2022_wide <- reshape(temp_carrizo2022, timevar = "microsite", v.names = "intensity", direction = "wide", idvar="hour_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (date,day,hour_OMEGA,day_humidity,temp,humidity,pendant_id,lat,long,region,site_code,sensor_pendant,rep)
## are really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Ephedra californica: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
write.csv(intensity_carrizo2022_wide, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/radiation_carrizo2022_wide.csv")


intensity_carrizo2022_wide<- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/radiation_carrizo2022_wide.csv")

rii.intensity.shrub.carrizo2022<- intensity_carrizo2022_wide %>%
  mutate(rii_calc_shrub = (intensity.Ephedra.californica-intensity.open)/(intensity.Ephedra.californica + intensity.open))


rii.intensity.triangle.carrizo2022<- intensity_carrizo2022_wide %>%
  mutate(rii_calc_triangle = (intensity.triangle-intensity.open)/(intensity.triangle + intensity.open))

rii.intensity.square.carrizo2022<- intensity_carrizo2022_wide %>%
  mutate(rii_calc_square= (intensity.square-intensity.open)/(intensity.square + intensity.open))


x7 <- select(rii.intensity.shrub.carrizo2022, rii_calc_shrub)
y7<- select(rii.intensity.triangle.carrizo2022, rii_calc_triangle)
z7<- select(rii.intensity.square.carrizo2022, rii_calc_square)
rii.final.intensity.carrizo2022<-cbind(x7, y7, z7)
###did not get any values for shrub or triangle
###does not work for humidity

write.csv(rii.final.intensity.carrizo2022, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_intensity_carrizo2022.csv")


rii_intensity_carrizo2022_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_carrizo2022_manual.csv")



ggplot(rii_intensity_carrizo2022_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Radiation")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Carrizo 2022') +   labs(fill = "Microsite") 
## Warning: Removed 646 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 646 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_intensity_carrizo2022_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Radiation", xlab = "Microsite", title = "Carrizo 2022")
## Warning: Removed 646 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_intensity_carrizo2022<- glm(rii~as.factor(microsite), data = rii_intensity_carrizo2022_manual, family="gaussian")

emmeans(lm_rii_intensity_carrizo2022, pairwise~microsite)###facilitation and triangle were facilitative 
## $emmeans
##  microsite           emmean     SE  df lower.CL upper.CL
##  Ephedra californica  0.313 0.0893 218    0.137   0.4895
##  square              -0.183 0.1067 218   -0.393   0.0277
##  triangle            -0.447 0.0375 218   -0.521  -0.3729
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate     SE  df t.ratio p.value
##  Ephedra californica - square      0.496 0.1392 218   3.565  0.0013
##  Ephedra californica - triangle    0.760 0.0969 218   7.851  <.0001
##  square - triangle                 0.264 0.1131 218   2.336  0.0531
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
### RII carrizo 2023
###humidity

humidity_carrizo2023_wide <- reshape(temp_carrizo2023, timevar = "microsite", v.names = "humidity", direction = "wide", idvar="hour_ELITECH")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,hourdate_HOBO,day_humidity,temp,intensity,pendant_id,lat,long,site_code,rep)
## are really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Ephedra californica: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
humidity_carrizo2023_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/humidity_carrizo2023_wide.csv")


rii.humidity.shrub.carrizo2023<- humidity_carrizo2023_wide %>%
  mutate(rii_calc_shrub = (humidity.Ephedra.californica-humidity.open)/(humidity.Ephedra.californica + humidity.open))


rii.humidity.triangle.carrizo2023<- humidity_carrizo2023_wide %>%
  mutate(rii_calc_triangle = (humidity.triangle-humidity.open)/(humidity.triangle + humidity.open))

rii.humidity.square.carrizo2023<- humidity_carrizo2023_wide %>%
  mutate(rii_calc_square = (humidity.square-humidity.open)/(humidity.square + humidity.open))


x5 <- select(rii.humidity.shrub.carrizo2023, rii_calc_shrub)
y5<- select(rii.humidity.triangle.carrizo2023, rii_calc_triangle)
z5<- select(rii.humidity.square.carrizo2023, rii_calc_square)
rii.final.humidity.carrizo2023<-cbind(x5, y5, z5)
###did not get any values for shrub or triangle
###does not work for humidity


###let's try RII for radiation
intensity_carrizo2023_wide <- reshape(temp_carrizo2023, timevar = "microsite", v.names = "intensity", direction = "wide", idvar="hourdate_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,hour_ELITECH,day_humidity,temp,humidity,pendant_id,lat,long,site_code,rep)
## are really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Ephedra californica: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
intensity_carrizo2023_wide<- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/radiation_carrizo2023_wide.csv")

rii.intensity.shrub.carrizo2023<- intensity_carrizo2023_wide %>%
  mutate(rii_calc_shrub = (intensity.Ephedra.californica-intensity.open)/(intensity.Ephedra.californica + intensity.open))


rii.intensity.triangle.carrizo2023<- intensity_carrizo2023_wide %>%
  mutate(rii_calc_triangle = (intensity.triangle-intensity.open)/(intensity.triangle + intensity.open))

rii.intensity.square.carrizo2023<- intensity_carrizo2023_wide %>%
  mutate(rii_calc_square= (intensity.square-intensity.open)/(intensity.square + intensity.open))


x6 <- select(rii.intensity.shrub.carrizo2023, rii_calc_shrub)
y6<- select(rii.intensity.triangle.carrizo2023, rii_calc_triangle)
z6<- select(rii.intensity.square.carrizo2023, rii_calc_square)
rii.final.intensity.carrizo2023<-cbind(x6, y6, z6)


write.csv(rii.final.intensity.carrizo2023, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_intensity_carrizo2023.csv")


rii_intensity_carrizo2023_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_intensity_carrizo2023_manual.csv")



ggplot(rii_intensity_carrizo2023_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Radiation")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Carrizo 2023') +   labs(fill = "Microsite") 
## Warning: Removed 10015 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 10015 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_intensity_carrizo2023_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Radiation", xlab = "Microsite", title = "Carrizo 2023")
## Warning: Removed 10015 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_intensity_carrizo2023<- glm(rii~as.factor(microsite), data = rii_intensity_carrizo2023_manual, family="gaussian")

emmeans(lm_rii_intensity_carrizo2023, pairwise~microsite)###all of them were not facilitative
## $emmeans
##  microsite           emmean     SE   df lower.CL upper.CL
##  Ephedra californica  0.202 0.0178 1244    0.167    0.237
##  square               0.345 0.0174 1244    0.311    0.379
##  triangle             0.317 0.0174 1244    0.283    0.351
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate     SE   df t.ratio p.value
##  Ephedra californica - square    -0.1433 0.0248 1244  -5.765  <.0001
##  Ephedra californica - triangle  -0.1150 0.0248 1244  -4.626  <.0001
##  square - triangle                0.0283 0.0246 1244   1.153  0.4819
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
###let's try RII for radiation for Mojave 2022

intensity_mojave2022_wide <- reshape(temp_mojave2022, timevar = "microsite", v.names = "intensity", direction = "wide", idvar="hour_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,date,temp,pendant_id,lat,long,site_code,rep) are really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Larrea tridentata: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
write.csv(intensity_mojave2022_wide, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/radiation_mojave2022_wide.csv")


intensity_mojave2022_wide<- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/radiation_mojave2022_wide.csv")

rii.intensity.shrub.mojave2022<- intensity_mojave2022_wide %>%
  mutate(rii_calc_shrub = (intensity.Larrea.tridentata-intensity.open)/(intensity.Larrea.tridentata + intensity.open))


rii.intensity.triangle.mojave2022<- intensity_mojave2022_wide %>%
  mutate(rii_calc_triangle = (intensity.triangle-intensity.open)/(intensity.triangle + intensity.open))

rii.intensity.square.mojave2022<- intensity_mojave2022_wide %>%
  mutate(rii_calc_square= (intensity.square-intensity.open)/(intensity.square + intensity.open))


x8 <- select(rii.intensity.shrub.mojave2022, rii_calc_shrub)
y8<- select(rii.intensity.triangle.mojave2022, rii_calc_triangle)
z8<- select(rii.intensity.square.mojave2022, rii_calc_square)
rii.final.intensity.mojave2022<-cbind(x8, y8, z8)


write.csv(rii.final.intensity.mojave2022, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_intensity_mojave2022.csv")


rii_intensity_mojave2022_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_mojave2022_manual.csv")



ggplot(rii_intensity_mojave2022_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Radiation")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Mojave 2022') +   labs(fill = "Microsite") 

ggline(rii_intensity_mojave2022_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Radiation", xlab = "Microsite", title = "Mojave 2022")

lm_rii_intensity_mojave2022<- glm(rii~as.factor(microsite), data = rii_intensity_mojave2022_manual, family="gaussian")

emmeans(lm_rii_intensity_mojave2022, pairwise~microsite)###facilitation by larrea and square
## $emmeans
##  microsite            emmean     SE df lower.CL  upper.CL
##  Larrea tridentata -3.08e-02 0.0085 63  -0.0478 -0.013793
##  square            -1.61e-02 0.0085 63  -0.0331  0.000925
##  triangle           1.05e-05 0.0085 63  -0.0170  0.017001
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate    SE df t.ratio p.value
##  Larrea tridentata - square    -0.0147 0.012 63  -1.224  0.4436
##  Larrea tridentata - triangle  -0.0308 0.012 63  -2.561  0.0339
##  square - triangle             -0.0161 0.012 63  -1.337  0.3803
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
###let's try RII for radiation for Mojave 2023

intensity_mojave2023_wide <- reshape(temp_mojave2023, timevar = "microsite", v.names = "intensity", direction = "wide", idvar="hourdate_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,hour_ELITECH,day_humidity,temp,humidity,pendant_id,lat,long,site_code,rep)
## are really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Larrea tridentata: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
intensity_mojave2023_wide<- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/radiation_mojave2023_wide.csv")

rii.intensity.shrub.mojave2023<- intensity_mojave2023_wide %>%
  mutate(rii_calc_shrub = (intensity.Larrea.tridentata-intensity.open)/(intensity.Larrea.tridentata + intensity.open))


rii.intensity.triangle.mojave2023<- intensity_mojave2023_wide %>%
  mutate(rii_calc_triangle = (intensity.triangle-intensity.open)/(intensity.triangle + intensity.open))

rii.intensity.square.mojave2023<- intensity_mojave2023_wide %>%
  mutate(rii_calc_square= (intensity.square-intensity.open)/(intensity.square + intensity.open))


x9 <- select(rii.intensity.shrub.mojave2023, rii_calc_shrub)
y9<- select(rii.intensity.triangle.mojave2023, rii_calc_triangle)
z9<- select(rii.intensity.square.mojave2023, rii_calc_square)
rii.final.intensity.mojave2023<-cbind(x9, y9, z9)


write.csv(rii.final.intensity.mojave2023, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_intensity_mojave2023.csv")


rii_intensity_mojave2023_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii_mojave2023_manual.csv")



ggplot(rii_intensity_mojave2023_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Radiation")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Mojave 2023') +   labs(fill = "Microsite") 
## Warning: Removed 6129 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 6129 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_intensity_mojave2023_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Radiation", xlab = "Microsite", title = "Mojave 2023")
## Warning: Removed 6129 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_intensity_mojave2023<- glm(rii~as.factor(microsite), data = rii_intensity_mojave2023_manual, family="gaussian")

emmeans(lm_rii_intensity_mojave2023, pairwise~microsite)###facilitation by larrea and square
## $emmeans
##  microsite            emmean      SE   df lower.CL upper.CL
##  Larrea tridentata -2.01e-03 0.00118 6231 -0.00433 0.000303
##  square             2.35e-03 0.00272 6231 -0.00298 0.007688
##  triangle           7.28e-05 0.00158 6231 -0.00302 0.003162
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate      SE   df t.ratio p.value
##  Larrea tridentata - square   -0.00436 0.00297 6231  -1.471  0.3051
##  Larrea tridentata - triangle -0.00209 0.00197 6231  -1.059  0.5397
##  square - triangle             0.00228 0.00315 6231   0.725  0.7489
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
### RII mojave winter 2023
###temp

temp_mojave2023winter_wide <- reshape(temp_mojave2023_winter, timevar = "microsite", v.names = "temp", direction = "wide", idvar="hour_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,date,intensity,pendant_id,lat,long,site_code,rep) are really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Larrea tridentata: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
write.csv(temp_mojave2023winter_wide, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_mojave2023winter_wide.csv")

temp_mojave2023winter_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_mojave2023winter_wide.csv")


rii.temp.shrub.mojave2023winter<- temp_mojave2023winter_wide %>%
  mutate(rii_calc_shrub = (temp.Larrea.tridentata-temp.open)/(temp.Larrea.tridentata + temp.open))

rii.temp.triangle.mojave2023winter<- temp_mojave2023winter_wide %>%
  mutate(rii_calc_triangle = (temp.triangle-temp.open)/(temp.triangle + temp.open)) 

rii.temp.square.mojave2023winter<- temp_mojave2023winter_wide %>%
  mutate(rii_calc_square = (temp.square-temp.open)/(temp.square+ temp.open)) 

x10<- select(rii.temp.shrub.mojave2023winter, rii_calc_shrub)
y10<- select(rii.temp.triangle.mojave2023winter, rii_calc_triangle)
z10<- select(rii.temp.square.mojave2023winter, rii_calc_square)
rii.final.temp.mojave2023winter<-cbind(x10, y10, z10)

write.csv(rii.final.temp.mojave2023winter, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.temp.mojave2023winter.csv")


rii_mojave2023winter_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.temp.mojave2023winter_manual.csv")


ggplot(rii_mojave2023winter_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Temperature")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Mojave Winter 2023')  +   labs(fill = "Microsite") 

ggline(rii_mojave2023winter_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Temperature", xlab = "Microsite", title = "Mojave Winter 2023")

lm_rii_mojave2023winter<- glm(rii~as.factor(microsite), data = rii_mojave2023winter_manual, family="gaussian")

emmeans(lm_rii_mojave2023winter, pairwise~microsite)
## $emmeans
##  microsite         emmean    SE df lower.CL upper.CL
##  Larrea tridentata 0.0472 0.019 69  0.00926   0.0851
##  squre             0.0221 0.019 69 -0.01584   0.0600
##  triangle          0.0326 0.019 69 -0.00528   0.0705
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                     estimate     SE df t.ratio p.value
##  Larrea tridentata - squre      0.0251 0.0269 69   0.934  0.6208
##  Larrea tridentata - triangle   0.0145 0.0269 69   0.541  0.8514
##  squre - triangle              -0.0106 0.0269 69  -0.393  0.9185
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
### RII mojave winter 2023
###intensity

intensity_mojave2023winter_wide <- reshape(temp_mojave2023_winter, timevar = "microsite", v.names = "intensity", direction = "wide", idvar="hour_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,date,temp,pendant_id,lat,long,site_code,rep) are really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Larrea tridentata: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
write.csv(intensity_mojave2023winter_wide, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/intensity_mojave2023winter_wide.csv")

intensity_mojave2023winter_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/intensity_mojave2023winter_wide.csv")


rii.intensity.shrub.mojave2023winter<- intensity_mojave2023winter_wide %>%
  mutate(rii_calc_shrub = (intensity.Larrea.tridentata-intensity.open)/(intensity.Larrea.tridentata + intensity.open))

rii.intensity.triangle.mojave2023winter<- intensity_mojave2023winter_wide %>%
  mutate(rii_calc_triangle = (intensity.triangle-intensity.open)/(intensity.triangle + intensity.open)) 

rii.intensity.square.mojave2023winter<- intensity_mojave2023winter_wide %>%
  mutate(rii_calc_square = (intensity.square-intensity.open)/(intensity.square+ intensity.open)) 

x11<- select(rii.intensity.shrub.mojave2023winter, rii_calc_shrub)
y11<- select(rii.intensity.triangle.mojave2023winter, rii_calc_triangle)
z11<- select(rii.intensity.square.mojave2023winter, rii_calc_square)
rii.final.intensity.mojave2023winter<-cbind(x11, y11, z11)

write.csv(rii.final.intensity.mojave2023winter, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.intensity.mojave2023winter.csv")


rii_intensity_mojave2023winter_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.intensity.mojave2023winter_manual.csv")


ggplot(rii_intensity_mojave2023winter_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Radiation")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Mojave Winter 2023')  +   labs(fill = "Microsite") 
## Warning: Removed 39 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 39 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_intensity_mojave2023winter_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Radiation", xlab = "Microsite", title = "Mojave Winter 2023")
## Warning: Removed 39 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_intensity_mojave2023winter<- glm(rii~as.factor(microsite), data = rii_intensity_mojave2023winter_manual, family="gaussian")

emmeans(lm_rii_intensity_mojave2023winter, pairwise~microsite)
## $emmeans
##  microsite         emmean    SE df lower.CL upper.CL
##  Larre tridentata  0.0142 0.103 30   -0.196    0.225
##  square            0.0224 0.103 30   -0.188    0.233
##  triangle         -0.3342 0.103 30   -0.545   -0.124
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                    estimate    SE df t.ratio p.value
##  Larre tridentata - square    -0.0082 0.146 30  -0.056  0.9983
##  Larre tridentata - triangle   0.3485 0.146 30   2.389  0.0590
##  square - triangle             0.3567 0.146 30   2.445  0.0522
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
### RII carrizo winter 2023
###temp

temp_carrizo2023winter_wide <- reshape(temp_carrizo2023_winter, timevar = "microsite", v.names = "temp", direction = "wide", idvar="hour_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,date,intensity,pendant_id,lat,long,site_code,sensor_pendant,rep) are
## really varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Ephedra californica: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
write.csv(temp_carrizo2023winter_wide, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_carrizo2023winter_wide.csv")

temp_carrizo2023winter_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/temp_carrizo2023winter_wide.csv")


rii.temp.shrub.carrizo2023winter<- temp_carrizo2023winter_wide %>%
  mutate(rii_calc_shrub = (temp.Ephedra.californica-temp.open)/(temp.Ephedra.californica + temp.open))

rii.temp.triangle.carrizo2023winter<- temp_carrizo2023winter_wide %>%
  mutate(rii_calc_triangle = (temp.triangle-temp.open)/(temp.triangle + temp.open)) 

rii.temp.square.carrizo2023winter<- temp_carrizo2023winter_wide %>%
  mutate(rii_calc_square = (temp.square-temp.open)/(temp.square+ temp.open)) 

x12<- select(rii.temp.shrub.carrizo2023winter, rii_calc_shrub)
y12<- select(rii.temp.triangle.carrizo2023winter, rii_calc_triangle)
z12<- select(rii.temp.square.carrizo2023winter, rii_calc_square)
rii.final.temp.carrizo2023winter<-cbind(x12, y12, z12)

write.csv(rii.final.temp.carrizo2023winter, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.temp.carrizo2023winter.csv")


rii_carrizo2023winter_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.temp.carrizo2023winter_manual.csv")


ggplot(rii_carrizo2023winter_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Temperature")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Carrizo Winter 2023') +   labs(fill = "Microsite") + ylim(-0.5,0.5)
## Warning: Removed 36 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 36 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_carrizo2023winter_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Temperature", xlab = "Microsite", title = "Carrizo Winter 2023")

lm_rii_carrizo2023winter<- glm(rii~as.factor(microsite), data = rii_carrizo2023winter_manual, family="gaussian")

emmeans(lm_rii_carrizo2023winter, pairwise~microsite)
## $emmeans
##  microsite           emmean   SE df lower.CL upper.CL
##  Ephedra californica  1.958 1.28 69   -0.605     4.52
##  square               0.999 1.28 69   -1.565     3.56
##  triangle             0.555 1.28 69   -2.008     3.12
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate   SE df t.ratio p.value
##  Ephedra californica - square      0.960 1.82 69   0.528  0.8579
##  Ephedra californica - triangle    1.403 1.82 69   0.772  0.7213
##  square - triangle                 0.444 1.82 69   0.244  0.9677
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
### RII carrizo winter 2023
###intensity

intensity_carrizo2023winter_wide <- reshape(temp_carrizo2023_winter, timevar = "microsite", v.names = "intensity", direction = "wide", idvar="hour_HOBO")
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : some constant variables
## (day,date,temp,pendant_id,lat,long,site_code,sensor_pendant,rep) are really
## varying
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=square: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=triangle: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=Ephedra californica: first taken
## Warning in reshapeWide(data, idvar = idvar, timevar = timevar, varying =
## varying, : multiple rows match for microsite=open: first taken
write.csv(intensity_carrizo2023winter_wide, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/intensity_carrizo2023winter_wide.csv")

intensity_carrizo2023winter_wide<-read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/intensity_carrizo2023winter_wide.csv")

rii.intensity.shrub.carrizo2023winter<- intensity_carrizo2023winter_wide %>%
  mutate(rii_calc_shrub = (intensity.Ephedra.californica-intensity.open)/(intensity.Ephedra.californica + intensity.open))

rii.intensity.triangle.carrizo2023winter<- intensity_carrizo2023winter_wide %>%
  mutate(rii_calc_triangle = (intensity.triangle-intensity.open)/(intensity.triangle + intensity.open)) 

rii.intensity.square.carrizo2023winter<- intensity_carrizo2023winter_wide %>%
  mutate(rii_calc_square = (intensity.square-intensity.open)/(intensity.square+ intensity.open)) 

x13<- select(rii.intensity.shrub.carrizo2023winter, rii_calc_shrub)
y13<- select(rii.intensity.triangle.carrizo2023winter, rii_calc_triangle)
z13<- select(rii.intensity.square.carrizo2023winter, rii_calc_square)
rii.final.intensity.carrizo2023winter<-cbind(x13, y13, z13)

write.csv(rii.final.intensity.carrizo2023winter, "C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.intensity.carrizo2023winter.csv")


rii_intensity_carrizo2023winter_manual <- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/rii.final.intensity.carrizo2023winter_manual.csv")


ggplot(rii_intensity_carrizo2023winter_manual, aes(microsite, rii, fill = microsite)) +
  geom_boxplot()+ ylab("Relative Interaction Index (RII) for Radiation")+ geom_hline(yintercept=0, linetype="dashed", color = "red")+ theme_classic() + xlab("Microsite")+  theme_classic()+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ stat_summary(fun.y=mean, colour="black", geom="point", shape=18, size=3,show_guide = FALSE) + ggtitle('Carrizo Winter 2023') +   labs(fill = "Microsite") 
## Warning: Removed 36 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 36 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggline(rii_intensity_carrizo2023winter_manual, x="microsite", y= "rii", add = "mean_se", ylab = "Relative Interaction Index (RII) for Radiation", xlab = "Microsite", title = "Carrizo Winter 2023")
## Warning: Removed 36 rows containing non-finite outside the scale range
## (`stat_summary()`).

lm_rii_intensity_carrizo2023winter<- glm(rii~as.factor(microsite), data = rii_intensity_carrizo2023winter_manual, family="gaussian")

emmeans(lm_rii_intensity_carrizo2023winter, pairwise~microsite)
## $emmeans
##  microsite           emmean    SE df lower.CL upper.CL
##  Ephedra californica -0.637 0.136 33   -0.914  -0.3597
##  square              -0.373 0.136 33   -0.650  -0.0963
##  triangle            -0.500 0.136 33   -0.777  -0.2234
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                       estimate    SE df t.ratio p.value
##  Ephedra californica - square     -0.263 0.193 33  -1.368  0.3689
##  Ephedra californica - triangle   -0.136 0.193 33  -0.708  0.7608
##  square - triangle                 0.127 0.193 33   0.661  0.7877
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
###smooth plots for max temperature

ggplot(temp_carrizo2022, aes((day), temp, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Temperature (°C)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Carrizo 2022')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggplot(temp_carrizo2023, aes((day), temp, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Temperature (°C)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Carrizo 2023')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggplot(temp_carrizo2023_winter, aes((day), temp, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Temperature (°C)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Carrizo Winter 2023')
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

ggplot(temp_mojave2022, aes((day), temp, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Temperature (°C)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Mojave 2022')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

ggplot(temp_mojave2023, aes((day), temp, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Temperature (°C)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Mojave 2023')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggplot(temp_mojave2023_winter, aes((day), temp, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Temperature (°C)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Mojave Winter 2023')
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

###smooth plots for max light radiation

ggplot(temp_carrizo2022, aes((day), intensity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Radiation (lum/ft²)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Carrizo 2022')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggplot(temp_carrizo2023, aes((day), intensity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Radiation (lum/ft²)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Carrizo 2023')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggplot(temp_carrizo2023_winter, aes((day), intensity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Radiation (lum/ft²)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Carrizo Winter 2023')
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

ggplot(temp_mojave2022, aes((day), intensity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Radiation (lum/ft²)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Mojave 2022')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

ggplot(temp_mojave2023, aes((day), intensity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Radiation (lum/ft²)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Mojave 2023')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggplot(temp_mojave2023_winter, aes((day), intensity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Radiation (lum/ft²)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Mojave Winter 2023')
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

###smooth plots for max humidity. Really only got good humidity for Carrizo and Mojave spring/summer 2023. 
ggplot(temp_carrizo2023, aes((day_humidity), humidity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Humidity (%)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Carrizo 2023') + xlim(0,30)
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 28875 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 28875 rows containing non-finite outside the scale range
## (`stat_summary()`).

ggplot(temp_mojave2023, aes((day_humidity), humidity, color=microsite)) + geom_smooth()+ xlab("Day") + ylab ("Humidity (%)")+ theme_classic()+ theme(axis.text=element_text(size=12))+stat_summary(fun.y=max, geom="point", size=2, aes(shape = microsite))+ labs(color="Microsite", shape= "Microsite") + theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))+ ggtitle('Mojave 2023')
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_summary()`).

###line graphs for temperature

ggline(temp_carrizo2022, x = "day", y = "temp", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Temperature (°C)", legend.title= "Microsite", legend="right")+ ggtitle('Carrizo 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0)))
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggline(temp_carrizo2023, x = "day", y = "temp", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Temperature (°C)", legend.title= "Microsite", legend="right")+ ggtitle('Carrizo 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0)))
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggline(temp_carrizo2023_winter, x = "day", y = "temp", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Temperature (°C)", legend.title= "Microsite", legend="right")+ ggtitle('Carrizo Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0)))

ggline(temp_mojave2022, x = "day", y = "temp", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Temperature (°C)", legend.title= "Microsite", legend="right")+ ggtitle('Mojave 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0)))

ggline(temp_mojave2023, x = "day", y = "temp", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Temperature (°C)", legend.title= "Microsite", legend="right")+ ggtitle('Mojave 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0)))
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggline(temp_mojave2023_winter, x = "day", y = "temp", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Temperature (°C)", legend.title= "Microsite", legend="right")+ ggtitle('Mojave Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0)))

###line graphs for radiation

ggline(temp_carrizo2022, x = "day", y = "intensity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Radiation (lum/ft²)", legend.title= "Fabric", legend="right")+ ggtitle('Carrizo 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  +  theme (axis.text.y = element_text(margin = margin(r=0))) 
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 1788 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggline(temp_carrizo2023, x = "day", y = "intensity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Radiation (lum/ft²)", legend.title= "Fabric", legend="right")+ ggtitle('Carrizo 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  +  theme (axis.text.y = element_text(margin = margin(r=0))) 
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 24193 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggline(temp_carrizo2023_winter, x = "day", y = "intensity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Radiation (lum/ft²)", legend.title= "Fabric", legend="right")+ ggtitle('Carrizo Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  +  theme (axis.text.y = element_text(margin = margin(r=0))) 

ggline(temp_mojave2022, x = "day", y = "intensity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Radiation (lum/ft²)", legend.title= "Fabric", legend="right")+ ggtitle('Mojave 2022')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  +  theme (axis.text.y = element_text(margin = margin(r=0))) 

ggline(temp_mojave2023, x = "day", y = "intensity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Radiation (lum/ft²)", legend.title= "Fabric", legend="right")+ ggtitle('Mojave 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  +  theme (axis.text.y = element_text(margin = margin(r=0))) 
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 17457 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggline(temp_mojave2023_winter, x = "day", y = "intensity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Radiation (lum/ft²)", legend.title= "Fabric", legend="right")+ ggtitle('Carrizo Winter 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1))  +  theme (axis.text.y = element_text(margin = margin(r=0))) 

###line graphs for humidity. Really only got good humidity for Carrizo and Mojave spring/summer 2023. 

ggline(temp_carrizo2023, x = "day_humidity", y = "humidity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Humidity (%)", legend.title= "Fabric", legend="right")+ ggtitle('Carrizo 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0))) + xlim(0, 30)
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 28875 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 16 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 16 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggline(temp_mojave2023, x = "day_humidity", y = "humidity", color = "microsite",
 add = "mean_se", shape = "microsite", xlab = "Day", ylab = "Humidity (%)", legend.title= "Fabric", legend="right")+ ggtitle('Mojave 2023')+ theme(panel.border = element_rect(color = "black",
                                    fill = NA,
                                    size = 1)) +  theme (axis.text.y = element_text(margin = margin(r=0))) + xlim(0, 30)
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning in base::min(x, na.rm = TRUE): no non-missing arguments to min;
## returning Inf
## Warning in base::max(x, na.rm = TRUE): no non-missing arguments to max;
## returning -Inf
## Warning in stats::qt(ci/2 + 0.5, data_sum$length - 1): NaNs produced
## Warning: Removed 26677 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_point()`).

library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
###Levene's Test for Homogeneity of Variance

leveneTest(temp ~ microsite, temp_carrizo2022) #variation in temperature between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  565.19 < 2.2e-16 ***
##       31538                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(temp ~ microsite, temp_carrizo2023)#variation in temperature between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  165.33 < 2.2e-16 ***
##       28581                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(temp ~ microsite, temp_carrizo2023_winter)#variation in temperature between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##         Df F value    Pr(>F)    
## group    3   10.64 5.946e-07 ***
##       2666                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(temp ~ microsite, temp_mojave2022)#variation in temperature between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  103.65 < 2.2e-16 ***
##       10292                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(temp ~ microsite, temp_mojave2023)#variation in temperature between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  1350.7 < 2.2e-16 ***
##       26673                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(temp ~ microsite, temp_mojave2023_winter)#variation in temperature between groups is not significant 
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##         Df F value Pr(>F)
## group    3  0.3957 0.7561
##       2059
leveneTest(intensity ~ microsite, temp_carrizo2022) #variation in intensity between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  898.54 < 2.2e-16 ***
##       31538                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(intensity ~ microsite, temp_carrizo2023)#variation in intensity between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3   146.4 < 2.2e-16 ***
##       28581                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(intensity~ microsite, temp_carrizo2023_winter)#variation in intensity between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##         Df F value    Pr(>F)    
## group    3  44.263 < 2.2e-16 ***
##       2666                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(intensity ~ microsite, temp_mojave2022)#variation in intensity between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  222.62 < 2.2e-16 ***
##       10292                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(intensity~ microsite, temp_mojave2023)#variation in intensity between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  124.12 < 2.2e-16 ***
##       26673                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(intensity ~ microsite, temp_mojave2023_winter)#variation in intensity between groups is significant 
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##         Df F value    Pr(>F)    
## group    3  6.3414 0.0002811 ***
##       2059                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(humidity ~ microsite, temp_carrizo2023)#variation in humidity between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value    Pr(>F)    
## group     3  226.62 < 2.2e-16 ***
##       24187                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(humidity~ microsite, temp_mojave2023)#variation in humidity between groups is significant
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value  Pr(>F)  
## group     3  2.3678 0.06872 .
##       17453                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Create microsite map for appendix
library(ggmap)
## ℹ Google's Terms of Service: <https://mapsplatform.google.com>
##   Stadia Maps' Terms of Service: <https://stadiamaps.com/terms-of-service/>
##   OpenStreetMap's Tile Usage Policy: <https://operations.osmfoundation.org/policies/tiles/>
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
register_google(key="AIzaSyBpfKtYrkYVS3LEJSjV1cIHeYrxJPsPX4U")

carrizo_mojave<-get_map(location = c(lon = -119.417931, lat = 36.778259), zoom = 6, maptype = "satellite")
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=36.778259,-119.417931&zoom=6&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxx>
lat_long<- read.csv("C:/Users/Nargol Ghazian/Desktop/PhD-Shelter-Shrub-Climate/shelters/camtraps/Sites 2023.csv")



Carrizo <- get_map(location = c(lon = -119.7929080, lat = 35.1913582), zoom = 11, maptype = "terrain")
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=35.191358,-119.792908&zoom=11&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx>
Tecopa<- get_map(location = c(lon = -116.226389, lat = 35.848333), zoom = 13, maptype = "terrain")
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=35.848333,-116.226389&zoom=13&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx>
ggmap(carrizo_mojave) +
  geom_point(data= lat_long, aes(x=long, y=lat, color = microsite), alpha = 6/10, size =3, show.legend = TRUE) +
  labs(title = "California, USA", x = "Longitude", y = "Latitude")+ theme(legend.position = "none")

ggmap(Carrizo) +
  geom_point(data= lat_long, aes(x=long, y=lat, color = microsite), alpha = 6/10, size =3, show.legend = TRUE) +
  labs(title = "Carrizo Plain National Monument", x = "Longitude", y = "Latitude")+ theme(legend.position = "none")
## Warning: Removed 40 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggmap(Tecopa) +
  geom_point(data= lat_long, aes(x=long, y=lat, color = microsite), alpha = 6/10, size =3, show.legend = TRUE) +
  labs(title = "Tecopa", x = "Longitude", y = "Latitude")+ theme(legend.position = "none")
## Warning: Removed 40 rows containing missing values or values outside the scale range
## (`geom_point()`).

```